-
Make sure that JAVA_HOME points to a version 11 jdk.
-
On OS X:
export JAVA_HOME=$(/usr/libexec/java_home 11)
-
-
Build everything and run the app with
./gradlew run
-
The output will show that 2 versions of the same module have been loaded at the same time:
Greetings from version ONE! Greetings from version TWO!
-
You can see the output at travis-ci: https://travis-ci.org/torstenwerner/java-9-no-jar-hell
The directories hello1 and hello2 contain almost the same code with just some small modification in the run() method. It simulates loading 2 different versions of the same module. It would be impossible to use both JARs in the same classpath. But it is possible to work around that limitation by constructing 2 ModuleLayer instances. That is what main code in Main.java is doing.
More information about Java 9 Jigsaw module system: http://openjdk.java.net/projects/jigsaw/
I have tested it with gradle 5.0.
Build at Travis CI
Instructions (use sudo on Linux):
docker pull openjdk:11-slim docker build -t java-9-no-jar-hell . docker run -it --rm java-9-no-jar-hell