How to set the language level (#1029)

Z2 compiles Java code (using a built-in Eclipse Java Compiler). Typically, you do not need to worry about language levels, as by default, Z2 simply sticks to the version of the Java Development Kit (or Java Runtime Environment) it is currently executed with.

That is, if you run a Java 6 JDK, then Z2 will compile for Java 6, if you run a Java 7 JDK, Z2 will compile for Java 7.

Note that Java 8 is not supported at the time of writing.

The language level used by the compiler can however be specified using the system property com.zfabrik.java.level.

The system property, if set, must match either "6" or "7" at this time.

Of course:

  • Specifying a value of "7" while running under Java 6 will lead to compile errors!
  • Trying to run with Java 7 source code under Java 6 will lead to compile errors.