I'm trying to create a modular, executable jar file, that can be run with java -p <jar file> -m <module>
on Java 9.0.1.
This works as expected when creating a jar 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 generated with mvn package
and mvn assembly:single
.
These maven generated jars still work with java -p test.jar -m test/test.Main
, and all the jars work on the classpath with java -jar test.jar
.
I inspected the jar contents with jar xf test.jar
, and found that the jars are exactly the same, except for the manifests (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
Notably, one still can't use java -p test.jar -m test
when specifying the working manifest:
$ 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: A repo with the expected behavior: https://github.com/deontologic/test