- As the older version of Java that is, Java 8 and before don't support modules, we would have to get rid of the module-info.java while compiling on an older version. So what we did was to not include module-info.java during our compilation. So we compiled using the following code:
$ javac --release 8 -d mods src\demo\com\packt\CollectionsDemo.java
You can see that we are using the --release option targeting Java 8 and not compiling the module-info.java.
- Let's create a JAR file because it becomes easier to transport the java build instead of copying all the class files:
$jar --create --file mlib/demo.jar --main-class com.packt.CollectionsDemo -C mods/ .
- Let's run the preceding JAR in Java 9:
$ java -version java version ...