Since in this unit we will only ask you to submit Java code, not compiled bytecode, all that matters is that any code you submit is compliant with the Java 11 specification. So long as you don't use any features introduced in more recent versions, this will be fine (e.g: https://openjdk.org/jeps/440 or https://openjdk.org/jeps/441, which were introduced with Java 21).
The most certain way to prevent yourself from accidentally using newer features is to install a Java 11 JDK, however there is indeed a flag to compile for a specific Java release: The --release
flag. Per javac --help
for OpenJDK 21:
--release
Compile for the specified Java SE release.
Supported releases:
8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21
So javac --release 11 MyClass.java
should do what you want, as it will throw an error if you try to use features that weren't available in release 11.