Create standalone executable from Java code for Windows, OSX and Linux all at once

廉价感情. 提交于 2019-12-08 12:57:48

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!