Create your own VM using Java Modules

Anish Antony
Javarevisited
Published in
7 min readFeb 13, 2021

--

Over this article lets explore the concept of Java Modules practically. Finally, let's create a small application by using java modules and its VM.

Photo by Daniel Wiadro on Unsplash

Java modules is one of the great feature introduced as part of Java 9. It improves your code with more strong encapsulation, It is able to reduce the size of the VM, improves the execution time, and so on.

Let's get into depth about the coding of java modules.

Java Module Project Structure

First, let's see how a java module project looks like. The details about java modules are configured on a file called module-info.java which is coming under the root folder. Inside of the file, it is specifying what are the dependent modules, what are the services which it offers, services which it consumes …etc.

The module-info.java file extension is java but it is not a class file or interface file. It is used for defining modules. The structure of the module-info.java file follows.

module lici.modules.gui {

}

In the above, it shows a simple module-info.java file structure. Here, it is defined as the module lici.modules.gui. It is able to add the additional dependent module directives inside the curly braces.

--

--

Anish Antony
Javarevisited

Fullstack Developer | Blogger | Experience on Java, Python, React, Angular, Golang | http://www.behindjava.com