Compiling and running modules

Let's first compile the HelloApp module and then the HelloClient module. Before running the command, make sure that the Java 9 ClassPath is set. To compile module code, the following command needs to run:

javac -d output com.packt.helloapp\com\packt\helloapp\HelloApp.java com.packt.helloapp\module-info.java

On successful compilation it will generate HelloApp.class and module-info.class into the output directory.

As our HelloApp module is required by the HelloClient module, we should generate the com.packt.helloapp module jar to include it in the HelloClient module. To create a jar in the mlib folder, run the following jar command:

jar -c -f mlib\com.packt.helloapp.jar -C output .

Now, remove the output directory ...

Get Java 9 Dependency Injection now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.