Writing modular code using a command-line interface

As a tradition, let's create a simple module called helloApp, which will have a simple message and will be required by another module called helloClient. Here, we will use a command line interface to create and run the module.

Create a helloApp module folder named com.packt.helloapp and a package folder named com\packt\helloapp:

mkdir com.packt.helloappmkdir com.packt.helloapp\com\packt\helloapp

Now, create a HelloApp.java component class under the package name com.packt.helloapp\com\packt\helloapp and a modue-info.java file at root folder com.packt.helloapp:

HelloApp.javapackage com.packt.helloapp;public class HelloApp {  public String sayHelloJava() { return "Hello Java 9 Module System"; ...

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.