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?
-
1Is it possible that the whole customized JRE will run on Linux only? AFAIK you'd have to run jlink on Windows for a Windows JRE. – Queeg May 03 '22 at 10:06
-
I don't then understand the whole idea of custom JRE. On Windows I can even create an executable instead of custom JRE, why do I even need it then? Before JDK 11, the client would just install the JRE, then I send them the jar or .class file which they run. Starting from JDK 11 there is no JRE that the client can install, so as I understood, I have to create the custom JRE on my own, which I then send to the client and they can run it wherever they want. – Kalich May 03 '22 at 10:31
-
The JRE is different for different platforms. You can't create a custom JRE for Windows (or any other non-Linux platform) if your full JRE (from the JDK) is the Linux version. – k314159 May 03 '22 at 10:43
-
1Yes, you have to run jlink on your target platform. 'Cross-linking' isn't possible. The platform-neutral element in Java is its bytecode. That which interprets that bytecode is platform-specfic – g00se May 03 '22 at 10:54
1 Answers
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/

- 7,748
- 1
- 16
- 42