I am trying to create a modular executable jar that can be run using java -p <jar file> -m <module>
on Java 9.0.1.
This works, as expected, when creating the flag with jar cfe test.jar test.Main -C classes/ .
, but throws module test does not have a MainClass attribute, use -m <module>/<main-class>
when generating with mvn package
and mvn assembly:single
.
These maven generated jars still work with java -p test.jar -m test/test.Main
, and all jars work along the class c path java -jar test.jar
.
I looked at the contents of the container with jar xf test.jar
and found that the jars are exactly the same, except for the manifest (see below):
Manifest-Version: 1.0
Created-By: 9.0.1 (Oracle Corporation)
Main-Class: test.Main
and
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: testuser
Build-Jdk: 9.0.1
Main-Class: test.Main
It is noteworthy that when specifying a working manifest you cannot use java -p test.jar -m test
:
$ jar cfm test.jar test-contents/META-INF/MANIFEST.MF -C classes/ .
$ java -p test.jar -m test
module test does not have a MainClass attribute, use -m <module>/<main-class>
Edit : repo with expected behavior: https://github.com/deontologic/test