JavaPackager
JavaPackager copied to clipboard
Java Modules support
I'm submitting a…
- [ ] bug report
- [X] feature request
- [ ] other
Short description of the issue/suggestion:
Add support for JPMS (Java Platform Modules System).
What is the expected behavior?
If Java version 9+ and root JAR is modular, then run java with --module and --module-path params.
What is the current behavior?
Currently all generated apps run in legacy mode (all JARs are passed to the JVM in the classpath - loaded in the unnamed module).
Do you have outputs, screenshots, demos or samples which demonstrate the problem or enhancement?
Running the app in legacy mode (non-modular main JAR):
java --class-path libs\*;${name}-${version}-runnable-jar ${mainclass} ${args}
Replace
;with:and\with/in classpath on Mac OS and GNU/Linux.
Running the app in modular mode (modular main JAR):
java --module-path=libs;${name}-${version}-runnable-jar --module=${modulename}/${mainclass} ${args}
${modulename} can be extracted from the JAR. Replace
;with:in classpath on Mac OS and GNU/Linux.
Please tell us about your environment:
- JavaPackager version: 1.7.0
- OS version: All platforms.
- JDK version: 9+
- Build tool:
- [X] Maven
- [X] Gradle
We have to determine which JARs are modular and copy them into mods folder, and which not and copy them into libs folder, when ${runnableJar} is modular (contains module-info). Then, we could run the app this way:
java --class-path=libs\* --module-path=mods;${name}-${version}-runnable-jar --module=${modulename}/${mainclass} ${args}
Maybe modular JARs could be "merged" with the generated JRE?
@fvarrui - I've always been rather perplexed at how difficult it has been to use a touted feature that is supposed to make everything cleaner and nicer. I've never once managed to compile a modular Java app into a self-contained package because there never seems to be a clear cut straightforward way to do it. If you manage to figure this out, your library will explode in the number of people who use it and I think that will even draw in more people to help support it. The simplicity that you offer with this library makes it VERY attractive and if that could also include modular projects? Pure GOLD!