on Ubuntu jlink does not generate .bat script, only bash script

145 Views Asked by At

I am trying to create a custom JRE with laucher scripts using this guide. I am running Ubuntu 20.04, and at the end I got only the bash script in the bin folder, but wasn't it supposed for jlink to create both .bat and bash scripts?

2

There are 2 best solutions below

0
On BEST ANSWER

Considering the question and the comments so far...

Either you go the traditional way and continue to distribute jar files. Your client can run the application on any machine that has a Java Runtime (and today that means they install the JDK as there is no JRE any more).

Or you package your application to include the JRE so the client does not have to care which version of Java they need. To make this easier, jlink and jpackage have been created. Have a look at https://docs.oracle.com/en/java/javase/17/jpackage/packaging-overview.html Just be aware Windows packages will have to be created on a Windows machine, Linux packages on a Linux machine etc. Cross-compiling is not supported.

If you prefer something like Webstart (which means automated online distribution of your application), take a look at https://openwebstart.com/

0
On

You can generate a Windows package on a Linux machine and vice versa, see Create Java runtime image on one platform for another using Jlink

For that you need the JDK of the target platform and point to its jmods module (jlink --module-path "path_to_a_Windows_JDK\jmods"). If you want to do it on a pipeline you can use mvn-jlink maven plugin that would download the required JDK.