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. Compile the code and place the compiled classes in a directory, say mods:
      javac -d mods --module-source-path . $(find . -name *.java)
  1. Build a modular JAR for the math.util module:
      jar --create --file=mlib/math.util@1.0.jar --module-version 1.0      -C mods/math.util .
Do not forget the dot (.) in the end in the preceding code. 
  1. Build a modular JAR for the calculator module, specifying the main class to make the JAR executable:
      jar --create --file=mlib/calculator@1.0.jar --module-version 1.0       --main-class com.packt.calculator.Calculator -C mods/calculator .

The critical piece in the preceding command is the --main-class option. This enables us to execute the JAR without providing the main class information ...

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