In Java 9, you can create a JAR file with
jar --create --file=mlib/com.greetings.jar --main-class=com.greetings.Main -C mods/com.greetings .
Which has the side effect of adding the MainClass attribute to the module-info.class file in the .jar file.
Do any of the plugins support this yet, or do I need to invoke the Java 9 'jar' command directly?
Is this the right forum to be asking these questions, or is there a better place?
Cheers, Eric
It is that file that defines a module's name, dependencies, and APIs. So there is a strong connection between JARs and modules: JARs are the containers from which the module system creates modules and (at the moment) each JAR can only contain a single module.
Java Module System is a major change in Java 9 version. Java added this feature to collect Java packages and code into a single unit called module. In earlier versions of Java, there was no concept of module to create modular Java applications, that why size of application increased and difficult to move around.
An unnamed module is a JAR that is built without module-info. java declaration. An unnamed module will require all other modules and will export all its packages as well. Type 2: Named Module. A named module is a module that is created with a module declaration file module-info.
The effect of the 'transitive' modifier is to cause additional modules to also depend on the other module. If module M 'requires transitive N', then not only does M depend on N, but any module that depends on M also depends on N.
The 'module main class' is actually an attribute of the module-info.class file. It's called ModuleMainClass
and set by the Java 9's jar
command. The current version (3.0.2) of maven-jar-plugin
only writes the file when you specify the manifest.mainClass
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With