O'Reilly logo

Java 9 Cookbook by Nick Samoylov, Mohamed Sanaulla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting ready

For this recipe, we will need a modular jar and a non-modular application. Our modular code can be found at chp3/4_modular_jar_with_pre_java9/math.util (this is the same math.util module that we created in our recipe, Creating a simple modular application). Let's compile this modular code and create a modular JAR by using the following commands:

javac -d classes --module-source-path . $(find math.util -name *.java)
mkdir mlib
jar --create --file mlib/math.util.jar -C classes/math.util .

We have also provided a jar-math.bat script at chp3/4_modular_jar_with_pre_java9, which can be used to create modular JARs on Windows. We have our modular JAR. Let's verify by using the -d option of the jar command: 

jar -d --file mlib/math.util@1.0.jar ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required