1

I have a modular project with 4 modules. One of which is a JavaFX application. The modules have a few dependency on maven libraries that are not modularised, like jasypt. When I try to make custom JRE for my project using JLink I get this error:

Error: automatic module cannot be used with jlink: jasypt

How to create custom jar for projects with dependency on non modular project?

Prashant Prakash
  • 105
  • 1
  • 10
  • I'm curious: Why do you build a custom JRE? – J Fabian Meier Sep 15 '20 at 18:15
  • There aren't enough details in your question to be able to help you. Can you put a ***small*** representative *example* of your project in github or something? Nothing major. Just an example that reproduces the error you're reporting. TIA. – deduper Sep 15 '20 at 19:18
  • Or just have a look into this tutorial https://github.com/mipastgt/JFXToolsAndDemos which teaches you exactly that. – mipa Sep 15 '20 at 21:43
  • @deduper Here's the github link to the project: https://github.com/Geek8080/Daily-Journal – Prashant Prakash Sep 16 '20 at 08:01
  • @mipa The link you provided doesn't have anything on JLink. – Prashant Prakash Sep 16 '20 at 08:04
  • @PrashantPrakash Uuupps, you are right. I just copied the wrong link. Here we go: https://github.com/dlemmermann/JPackageScriptFX – mipa Sep 16 '20 at 10:22
  • The first thing I did was run *`mvn verify`*. [*The project failed to build*](https://github.com/Geek8080/Daily-Journal/issues/3) for me. Your [*`PrimaryController`*](https://github.com/Geek8080/Daily-Journal/blob/master/Diary/src/main/java/org/geek8080/journal/main/PrimaryController.java#L10) and [*`SecondaryController`*](https://github.com/Geek8080/Daily-Journal/blob/master/Diary/src/main/java/org/geek8080/journal/main/SecondaryController.java#L10) classes call an *`App.setRoot(String)`* method that does not exist. That issue needs to be fixed before your jlink issue can be looked into. – deduper Sep 16 '20 at 10:45
  • @deduper Hey just fixed it. I didn't had those files on local repo. I forgot to remove them from the GIT – Prashant Prakash Sep 16 '20 at 11:09
  • @mipa My project is Java 11 project and the JPackage is shipped with Java 14. There's no JPackage tool in Java 11. And the link is not appropriate to the question. I have to work with jlink tool for projects with non-modular dependency. The link does not address to this issue. – Prashant Prakash Sep 16 '20 at 11:52
  • 1. You can use the jpackage tool from JDK 14+ to build installers which use a Java 11 runtime. That's no problem. 2. The whole tutorial is about dealing with non-modular dependencies. Read it again. (I am the co-author of this tutorial) It uses jlink to create a dedicated runtime based on the output of jdeps. This dedicated runtime is then packages via jpackage. – mipa Sep 16 '20 at 12:01
  • Thx @PrashantPrakash. Instead of the *`jasypt`* error that you got, I get „*`automatic module cannot be used with jlink: poi.ooxml`*“. Same issue though. I expected applying [*this plugin*](https://old.reddit.com/r/java/comments/aqhr50/jlink_and_automatic_modules/) would resolve your issue. But that plugin fails with [*this inexplicable NPE*](https://github.com/moditect/moditect/issues/91). With that, I'm stumped. – deduper Sep 16 '20 at 13:01
  • @mipa I followed the link you provided but I am getting an error while `mvn clean install` . Here's the stackTrace: [link](https://pastebin.com/AmCWPvrx) Here's the bat file [link](https://pastebin.com/GCP8VacC) – Prashant Prakash Sep 17 '20 at 06:21
  • Does the unmodified project work for you? My guess is you don't have any modules, so the path is empty. – mipa Sep 17 '20 at 07:43
  • The project is working fine. I think the library files are not copied to the target/installer/libs directory – Prashant Prakash Sep 17 '20 at 08:03
  • @mipa I was copying dependency to lib folder but copying from libs folder. Fixed it and now its generating the installer. But on installing and running the application I get `Failed to Launch JVM` error dialog. – Prashant Prakash Sep 17 '20 at 08:16
  • Sorry, but I can't help you with debugging that. The concept and the script works on Windows. I create installers for customers that way. – mipa Sep 17 '20 at 08:21
  • @mipa Thank you very much for the link. The problem was, I was not passing the javafx main class but the launcher for generating deps. On changing it to the jvafx class(class extending Application) it worked. – Prashant Prakash Sep 17 '20 at 08:49

0 Answers0