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

How to do it...

  1. Let's compile the modules:
      $ javac -d mods --module-path mlib --module-source-path src $(find       src - name *.java)
  1. Let's create the modular JAR for all the modules:
      $ jar --create --file mlib/math.util.jar -C mods/math.util .       $ jar --create --file=mlib/calculator.jar --main-      class=com.packt.calculator.Calculator -C mods/calculator/ .
  1.  Let's use jlink to create a run time image consisting of the modules: calculator, math.util and its dependencies:
      $ jlink --module-path mlib:$JAVA_HOME/jmods --add-modules       calculator,math.util --output image --launcher       launch=calculator/com.packt.calculator.Calculator

The run time image gets created at the location specified with --output command line option. 

  1. The run time image ...

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