0

We currently ship a java(jar) installer of our application. Taking into acount the changes to jdk11 we want our users to have the same easy install experience. So, what we are looking for, is to have just one file that can be run even if there is no java installed, it should just start our old java installer.

Probably, this means that we jave to bundle the jre and have a script that runs the jar, but the problem is how to run the batch file natively ? We need this to work on Windows and Mac. Most tools we are looking into require java to run the wrapped jar.

  • 2
    Possible duplicate of [How to bundle a JRE with Launch4j?](https://stackoverflow.com/questions/7071133/how-to-bundle-a-jre-with-launch4j) – Progman Jan 11 '19 at 19:00

2 Answers2

0

You have to build 2 different scripts/installers, one for each platform. Even looking at very popular software like Chrome, the platform choice is still there (even though you're usually directed to the correct choice based on the information your browser provides them with)

Depending on how much time you can put in this task, the quickest (and dirtiest) solution would be having an archive for each platform that contains the script .bat for Windows and .sh for OS X together with the jre (also different per platform), ask the user to unarchive and run the script which will run your jar with the packed jre. Otherwise, you'll need to create an MSI/exe for windows and a dmg (or other installer type) for MacOs.

I have done the dmg before with a bundled jre and can try to look for the details if you need them (I no longer have access to the code but can probably find the details). It was a free solution but it did require an OS X computer to create the dmg.

One option that I used before and works very well is install4j but the price is not small.

LE: Self contained packaging - although I haven't used this before, it seems like the best current option for your problem.

And an open source option - packr.

Vlad Topala
  • 857
  • 1
  • 8
  • 31
0

that Self Contained packaging doesn't really help, same for packr, same for launch4j. Because all those just generate a application image with a lot of files and directories.

Problem is before that, as an installer you want 1 big exe (or dmg for mac) that does it all, single click We are already at the stage like SCP or Packr. Because that is easy or current installer.exe and jre\ sub dir and a batch/sh file besides it. Problem is how to get from that directory structure to a single exe that runs.

So what we should have is something that can zip that in a self extracting archive, when clicking on that it should auto extract to the temp dir of the OS, then run directly a command on it (like a batch file or directly in that extracted dir: .\jre\bin\javaw.exe -jar installler.jar) But nobody seems to have made such a thing, the closest that we have is eclipse with Oomph:

[1] https://git.eclipse.org/c/oomph/org.eclipse.oomph.git/tree/plugins/org.eclipse.oomph.extractor/src/extractor.c

[2] https://git.eclipse.org/c/oomph/org.eclipse.oomph.git/tree/plugins/org.eclipse.oomph.extractor.lib/src/org/eclipse/oomph/extractor/lib/BINExtractor.java

problem is a bit that is doing the extracting through java and still wants a vm first.