5 ms·
You're doing it wrong. Like way wrong. Use jlink. It creates a double-clickable .exe from your JDK installation, pared down to a JRE for distribution. Works
by WkndTriathlete 3y ago
You're doing it wrong. Like way wrong.
Use jlink. It creates a double-clickable .exe from your JDK installation, pared down to a JRE for distribution. Works on Linux and Windows.
- geokon 3y agocould you give me a link on how it's done? I looked into this extensively and there was no way to bundle an .exe . It was a 2-3 years ago so maybe things have changed
- lbalazscs 3y agojlink only creates a runtime (the parts of the JDK that are actually used by your app), but there's a relatively new command called jpackage for creating installers: https://docs.oracle.com/en/java/javase/21/jpackage/packaging-overview.html https://docs.oracle.com/en/java/javase/21/jpackage/packaging... EDIT: I see now that you already know jpackage, but you don't want an installer. In that case you can use launch4j, which just wraps a jar in an exe: https://launch4j.sourceforge.net/ https://launch4j.sourceforge.net/
- geokon 3y agookay, Launch4j is new to me - but this seems to only work for Windows I find the whole situation a bit silly, bc obviously it's creating an executable under the hood somewhere. The official tools just don't expose it to you. I think what I could do is to run the installers on all target systems and then pull out the executables manually. I just think that'd be a bit difficult/annoying to make as part of a CI system
- lbalazscs 3y agoI only used Launch4j on Windows, but in the downloads you can find Linux and MacOS versions as well. At the bottom of the webpage it explains that it can be built on even more platforms, if you have MinGW binutils 2.22 (windres and ld only) on those platforms. If I remember correctly, you can't just pull out the exe created by jpackage, because it doesn't contain the runtime. The installer installs both the runtime and the exe. The exe created by Launch4j also doesn't include the runtime, but Launch4j is better at finding a system-wide runtime, and can direct the user to a specific download site (such as adoptium.net) instead of java.com. If you want to have JUST a single exe, then I think GraalVM's native image is the only option.
- geokon 3y agoHmmm,yeah I should really just try GraalVM. JavaFX finally supports it. I just remmeber it was a bit unclear how to hook it up with Clojure/deps.edn but I'm sure the tooling has evolved since I last looked Some day they'll integrate cosmopolitan builds with Graal native and we'll come full circle to cross-platform executables haha Edit : https://github.com/oracle/graal/issues/4854 https://github.com/oracle/graal/issues/4854