This article contains Java 9 module example using maven. In order to provide reliable configuration and strong encapsulation in a way that is both approachable to developers and supportable by existing toolchains, we treat modules as a fundamentally new kind of Java program component. A module is a named, self-describing collection of code and data. Its code is organized as a set of packages containing types, i.e., Java classes and interfaces; its data includes resources and other kinds of static information.


  • Java 9
  • Maven 2.5
  • Maven compiler plugin 3.6.0

Module Structure



module declaration

A module’s self-description is expressed in its module declaration, a new construct of the Java programming language.

 * Created by JavaDeveloperZone on 22-04-2017.
module module.maven.demo {
 requires java.logging;

package com.javadeveloperzone;

import java.util.logging.Logger;

 * Created by JavaDeveloperZone on 22-04-2017.
public class Demo {
 public static void main(String... args) {
 Logger logger=Logger.getLogger(Demo.class.getName());"This is module demo using maven");


<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=""





Build Project:

"C:\Program Files\Java\jdk-9\bin\java" -Dmaven.multiModuleProjectDirectory=F:\extrawork\java9-demo\module-maven-demo -Xmx2g -XX:ReservedCodeCacheSize=512m "-Dmaven.home=C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2017.1\plugins\maven\lib\maven3" "-Dclassworlds.conf=C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2017.1\plugins\maven\lib\maven3\bin\m2.conf" "-javaagent:C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2017.1\lib\idea_rt.jar=65380:C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2017.1\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2017.1\plugins\maven\lib\maven3\boot\plexus-classworlds-2.5.2.jar" org.codehaus.classworlds.Launcher -Didea.version=2017.1 clean
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building com.javadeveloperzone 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ com.javadeveloperzone ---
[INFO] Deleting F:\extrawork\java9-demo\module-maven-demo\target
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.170 s
[INFO] Finished at: 2017-04-22T11:30:07+05:30
[INFO] Final Memory: 8M/28M
[INFO] ------------------------------------------------------------------------

Process finished with exit code 0


INFO: This is module demo using maven


Was this post helpful?
Let us know, if you liked the post. Only in this way, we can improve us.

Leave a Reply

Your email address will not be published. Required fields are marked *