Stubbornly insisting on using JLINK for deployment

I’ve managed to write a working self-contained .exe for deployment, using the tool javapackager. I’m resisting deploying because I’d like to use the smaller runtime I made with JLINK.

The documentation on this is really difficult, imho. Maybe I am just being too stubborn (e.g., just package the complete runtime, or, learn ANT and try to follow the documentation on that path instead of javapackager).

Question for the more experienced folks at JGO:

  1. How bad is it to have an app be, say, 180MB instead of 80MB? The app itself has a lightweight feel to it–maybe comprises 3MB of code. Are people who are willing to try plunking down $3 or $4 say going to be okay with this project size? (Down the road, I have some projects I was going to aim at $1. Will having a full JRE selfcontained with each be a problem for something this “small”?)

  2. Does anyone happen to know if javapackager is even capable of deploying a jlink-generated runtime? (If you can answer this, consider also answering my question at Stack Overflow. Or, I can transfer the info over.)

So much whoop-de-do in books on Safari online about how the jlink runtime runs faster, can be used for more efficient deployments, etc., but I am unable to find one that details the actual deployment process for Windows (or any OS). And the “official” guide is a difficult read, confusingly organized, and relies deeply on Ant.

(SIDE ISSUE: Not entirely clear to me even how to use the .exe yet–the deployment guide and tutorials I have found don’t give examples–they assume people already know that? But what if this is your first time? My result includes ToneCircleDrone-1.0.exe and a file folder with src and runtime. Now what?)

:clue:

Thanks for any help.

This works for me:

[quote]"%JAVA_HOME%\bin\javapackager" ^
-deploy ^
-native exe ^
-outdir RELEASE ^
-srcdir . ^
-srcfiles config.json ^
–module-path target/modules ^
–add-modules java.management,jdk.naming.dns,java.security.jgss ^
–module net.webhotelier.avl/net.webhotelier.avl.Main ^
-name “WHJA” ^
-vendor “WebHotelier” ^
-v ^
-BjlinkOptions=“compress=2”
[/quote]
I get a WHJA-1.0.exe in the RELEASE folder, which is a native Windows installer. When installed, the app folder contains config.json & WHJA.cfg, the runtime folder contains the jlinked runtime.

I wasted too much time on this and it feels like javapackager and jlink are not integrated as well as they ought to. The issues I have identified:

  1. javapackager’s --module-path acts weirdly. I had to put all modular jars in the same directory for it to work. With jlink I can mix directories & individual jars in the same path without problems.
  2. I had to use the undocumented -BjlinkOptions to get a jlink minimized image. Without it I get a smaller installer (~18MB), but the installed application contains all modules (~107MB total). With compress=2, I get a bigger installer (~37MB), but the installed application contains only the modules necessary (~51MB total).
  3. It’s impossible to pass multiple jlink options (e.g. both --compress=2 and --no-header-files). Had a look at the source and it looks like a bug in javapackager’s argument parsing.

If I were you, I’d use jlink directly and bundle the resulting image with a third-party solution to create the native installers/executables. Note that the Java Packager tool has always been part of JavaFX, which means a) don’t expect software quality excellence and b) its future is questionable.

@Spasi – I’d like to give you multiple appreciations for answering!

For a 3rd party, I guess I’ll take a look at Inno Setup and WiX first. I’ll have to figure out what their differences are–both are required for the .exe deployment by the Java Packaging tool, according to the Deployment Guide.

If you have another preference, would like to hear about it. My experience with JSmooth though was that I couldn’t get past the sparse and ambiguous documentation. Maybe it is me, that everything I read tends to look like a funhouse hall of mirrors and it takes a great deal of effort to nail things down.

Can I ask what the JSON file you have for srcfiles consists of?

Thanks again!

I thought it was one or other?! :-\

Just changed to using InnoSetup for PraxisLIVE - found it really simple to set up by itself, and I like that I can run it / script it with WINE! 8)

[quote]3. It’s impossible to pass multiple jlink options (e.g. both --compress=2 and --no-header-files). Had a look at the source and it looks like a bug in javapackager’s argument parsing.
[/quote]
I found a book on Safari, “Java 9 Revealed” author Kishori Sharan 2017, which lists the syntax for this.

jlink <options> --module-path <modulepath> --add-modules <mods> --output <path> 

-c, --compress <0|1|2>[:filter=<pattern-list>]

--no-header-files

--no-man-pages


This implies that these can be space-delimited at the front end of the javapackager command (prior to --module-path). Did you try this exact ordering? (I’m guessing you did, but on the off chance this might still be relevant…)

[quote=“philfrei,post:3,topic:59488”]
We’re using jlink, compressing the result, then deploying that to servers, so I don’t have experience with installers. But I know there are plenty of (free & commercial) options you could try.

[quote=“philfrei,post:3,topic:59488”]
Nothing special, just some settings for the application. It was a test to see how you may add random files to a bundle, in addition to the modular stuff.

[quote=“philfrei,post:5,topic:59488”]
The problem is that javapackager does not call jlink (the cli command) internally, it uses the jlink API directly. The user arguments to jlink are supposed to be a key/value map, but parsing is broken somehow and you can effectively pass a single argument only.

I use NSIS-Ant in JNDT, maybe it could be useful for you.

Thanks gouessej. I’m feeling rather stupid at the moment, but I may have this solved.

Really stupid.

I was taking Spasi’s advice and nsigma’s encouragement to use Inno Setup. But I totally missed that all you have to do, to run it, is click the “Inno Setup Compiler” and a Wizard is offered. ::slight_smile:

Maybe it was a side effect of all that command-line stuff I was doing with module-compilation and jlink and attempts to use javapackager. The notion that there would be a Wizard didn’t occur to me.

OK, still have to figure out how to include all the file folders needed. Heading back in for more.

EDIT1: Now, only hitch is that the .bat file that launches the app is being copied to the top folder location in the target set of folders. Should be a solvable problem.

EDIT2: Easy work-around. Write a new .bat and place it in the /dist folder created by JLINK. Have this .bat simply call the .bat file in dist/bin that kicks things off.

OK. Next step, tighten up the JLINK command. Also, have to set up a zip of the .xml files which provide content, that can be downloaded. Still some tasks to do. Feels weird not being totally blocked any more and able to make some real progress.

Yes, the UI and wizards are useful, and it can still be used from the CLI / embedded in your build later when it works (eg. lots of resources for setting up with Ant). I looked at NSIS too, but didn’t appeal, and as soon as I figured I could use InnoSetup just as easily on Linux and in the build system it was a no brainer. :slight_smile:

Something wrong in your setup though if you’re having to move things around to get them to work.

er wut? InnoSetup works on Linux?

Cas :slight_smile:

@princec - as earlier message, with WINE, yes. :wink: I think it works fine on macOS that way too. There’s various ways of then using it within a build system, executing the build script via WINE without UI. AFAIK, there’s also a Linux tool for extracting the binaries from its installer directly (without running it). I’ve read a few posts of people then setting it up within travis-ci, etc. - not got that far yet! :smiley:

NSIS works under GNU Linux too and I use it with Ant.

You are all quite over my head on this!

I’m just happy to have (a) figured out the dang commands to get the icons to show correctly. The examples in INNO SETUP extract icons from within the .exe, which is not exactly helpful for the JLINK situation, since JLINK creates a .bat not an .exe; (b) figured out how to keep the command shells minimized. I’m not running a single copy in full-screen, but am allowing (expecting) multiple iterations to run at the same time and don’t want the screen cluttered with DOS shells.

It only took four days. :stuck_out_tongue:

Hi Julien - thanks for mentioning that about NSIS, I had no idea it ran under Linux. NSIS is great, if a little old-fashioned in its scripting language.

Cas :slight_smile:

Yes, NSIS works natively under Linux, but that scripting language! :persecutioncomplex: I did mention that earlier, Julien, but as soon as I figured out how easy Inno Setup worked via Wine libs I was happier with that.

@philfrei - I assume you’ve found the online docs for Inno Setup, or are they available in the app too? I also had to do the icons thing, although NetBeans RCP uses an .exe so no need for the minimize. Isn’t there a way to alter the script so that the console window closes as soon as the JVM is up? Sure I’ve seen that somewhere.

If it’s of interest, I just pushed my initial iss file to GitHub. It works - I’m not sure it’s good! ;D One thing I did do, relevant to what you said earlier, is comment out the line that copied the launcher into the root folder, and just copy across all the subfolders - editing the icon links to match.

[quote=“philfrei,post:13,topic:59488”]

[quote=“nsigma,post:15,topic:59488”]
I forgot to mention that we don’t use the .bat/.sh script that jlink generates. It’s very minimal and there’s basically no way to make jlink generate anything interesting in it (e.g. you’d need to manually edit to set JLINK_VM_OPTIONS). The service launcher just runs the java executable with the appropriate arguments.

nsigma wrote:

Thanks for checking back on those issues, nsigma.

Yes, the examples and docs are packed with the application and I did find them.
Yes, one can add “runminimized” as a “Flag” for the “Icon” tag. I didn’t see an example, though, since I didn’t take the time to locate any examples that run a bat.

There should be a common scale for documentation quality. Maybe this (scale of 1-5):

  1. no doc or contains many inaccuracies (worse than none?)
  2. many gaps (includes: references to things not explained)
  3. relatively complete info but not well organized, sparse examples
  4. able to index in, locate specific issues/scenarios
  5. info works for scanning/speed-reading intake (with clear drill-down paths and easy to locate examples)

6!) your specific scenario has been anticipated and dealt with

I would place INNO SETUP 5 at about 3.5 on this scale.

But, such a scale being linear, and problems being orthogonal to each other, the scale has its drawbacks.