• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Questions about modulepath when using jlink on a jmod file

 
Ranch Hand
Posts: 36
4
Netbeans IDE Python Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Heyo all, got a question about creating a runnable image which I'll eventually be packaging per platform. I have everything building into a runnable jar, but I want to package the runtime with it so that users don't have to worry about downloading anything other than my application itself. I'm using Java 12.

I've been following through the steps given here, and have build my .jmod from the runnable jar. (https://stackoverflow.com/questions/53453212/how-to-deploy-a-javafx-11-desktop-application-with-a-jre)

Here is the module-info.java I'm using:



This is the line I'm using to create the jmod:



Here is the jlink line I'm using to try to use to create my image:



Unfortunately, none of the required modules are being recognized by jlink. It tells me that their layouts are missing (the module that it errors on is random, just one from the required list):



I have checked inside the jar file that the jmod was created from, and it contains the compiled classes of everything that should be needed. Is there a way to tell jlink how to find it all? Everything needed should be in there already. Appreciate any assistance.
 
Draque Thompson
Ranch Hand
Posts: 36
4
Netbeans IDE Python Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Solved this myself and thought I would post the answer to anyone who happened across this with similar problems...

If you're going to use jlink in this manner, you should use a jar that has been built without dependencies. I was trying to use one that had been built with, which was where I was running into my problems. You will need to provide paths to copies of all modules that are required based on your requirements as defined in your  module-info.java. Just as an example, here is what my jlink line looks like now (line breaks added for clarity, but cannot be present when executed):



If you try to link based on a jar that has been built with dependencies, you will run into problems. When you fail to provide module paths, jlink will not be able to link everything. When you do provide them, you will run into collisions, as they already exist within your archive.
 
Saloon Keeper
Posts: 10539
224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reporting back to us!
 
Sheriff
Posts: 21788
104
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Maven JLink Plugin may make it easier to do this. It's still pre-release though (the site just shouts that it is...).
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
Enterprise-grade Excel API for Java
https://products.aspose.com/cells/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!