问题
i'm coding a project in Java and building it with gradle. I need to keep it simple and compile it into standalone binaries for Windows, Mac and Linux.
Is there anything which can build all of this binaries or must i use a separate lib (like Launch4j for Windows executables) for every single binary?
I'd like to call a single "build-all-binarys"-like task in gradle and get a .exe, .app and .bin file out of it. It would be nice to have the possibility to bundle a JRE into the binary as well.
回答1:
Use the javapackager, added since Java 8 in the JDK.
It nicely creates a self contained executable - that's it bundles the JVM with every copy - of all standard operating systems with one call.
The javapackager is located in JAVA_HOME/bin/ directory.
来源:https://stackoverflow.com/questions/41338591/create-standalone-executable-from-java-code-for-windows-osx-and-linux-all-at-on