一次性创建用于Windows,OSX和Linux的Java代码的独立可执行文件 [英] Create standalone executable from Java code for Windows, OSX and Linux all at once

查看:119
本文介绍了一次性创建用于Windows,OSX和Linux的Java代码的独立可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用Java编写一个项目,并用gradle构建它。
我需要保持简单,并将其编译到Windows,Mac和Linux的独立二进制文件中。



有什么可以构建所有这些二进制文件或必须的我为每个二进制文件使用单独的lib(像Launch4j for Windows可执行文件)?



我想调用一个build-all-binarys任务在gradle中获取.exe,.app和.bin文件。
如果有可能将JRE捆绑到二进制文件中将会很好。

,自从JDK中的Java 8开始被添加。

它很好地创建了一个自包含的可执行文件 - 它将JVM与每一个拷贝捆绑在一起 - 所有标准操作系统都只有一个调用。

javapackager位于JAVA_HOME / bin /目录中。


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.

解决方案

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.

这篇关于一次性创建用于Windows,OSX和Linux的Java代码的独立可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆