Issue
I have created a Java application runtime image using jlink. I would like to be able to ship the software as an executable to different platforms. (Preferably by building on one platform, like cross-compiling.)
Ideally, it would be a single application file that users may double-click to launch, without installing anything.
How can this be accomplished?
Solution
What you're describing is what's called a native executable. There are programs that will wrap your Java application into an executable file but because Java runs it's code on the Java Virtual Machine (JVM), your users will need to have it pre-installed for your program to work out of the box. You can code an installer for your application in something like C++ or C# (C# runs on the .NET Runtime which comes pre-installed on all Windows machines) that installs the JVM and possibly your application alongside it, and then compile that code to a native executable. That way, the end user doesn’t need to go looking around for Java downloads. This is the approach that Minecraft takes I believe.
Wrap your Java executable into a native executable using any of:
Launch4J (Windows)
Oracle Docs (MacOS)
Discourse (Linux)
Quarkus (native executable, no installer)
Warp Packer (self-extracting executable, no installer)
Answered By - DudeManGuy
Answer Checked By - Gilberto Lyons (JavaFixing Admin)