• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Questions about modulepath when using jlink on a jmod file

 
Ranch Hand
Posts: 74
6
Netbeans IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 74
6
Netbeans IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 15524
364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for reporting back to us!
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...).
 
A magnificient life is loaded with tough challenges. En garde tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic