使 Java 程序成为独立的 exe(无需 JVM 运行)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6700311/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 16:57:32  来源:igfitidea点击:

Make Java program as independent exe (run without JVM)

javajvmexe

提问by Eng.Fouad

Is there any way to make Java program as independent exe (run without JVM)?

有没有办法让Java程序成为独立的exe(没有JVM运行)?

采纳答案by Ladlestein

I've used Excelsior JETto compile my Java into a native executable file on Windows. It worked real well. There are always opportunities for gotchas - I think JNI is a problem - but I was pretty happy.

我使用Excelsior JET将我的 Java 编译成 Windows 上的本机可执行文件。它工作得很好。总是有机会遇到问题——我认为 JNI 是一个问题——但我很高兴。

回答by g051051

http://gcc.gnu.org/java:

http://gcc.gnu.org/java

GCJ is a portable, optimizing, ahead-of-time compiler for the Java Programming Language. It can compile Java source code to Java bytecode (class files) or directly to native machine code, and Java bytecode to native machine code.

Compiled applications are linked with the GCJ runtime, libgcj, which provides the core class libraries, a garbage collector, and a bytecode interpreter. libgcj can dynamically load and interpret class files, resulting in mixed compiled/interpreted applications. It has been merged with GNU Classpath and supports most of the 1.4 libraries plus some 1.5 additions.

GCJ 是用于 Java 编程语言的可移植、优化、提前编译器。它可以将Java源代码编译为Java字节码(类文件)或直接编译为本地机器码,将Java字节码编译为本地机器码。

编译后的应用程序与 GCJ 运行时 libgcj 链接,后者提供核心类库、垃圾收集器和字节码解释器。libgcj 可以动态加载和解释类文件,导致混合编译/解释的应用程序。它已与 GNU Classpath 合并,并支持大多数 1.4 库以及一些 1.5 添加。

回答by Sergii Zagriichuk

:) Just a example, you can build exe with internal JVM and user will see just exe file but your JAVA program will start and work on internal JVM for this case you can use exe4j

:) 只是一个例子,您可以使用内部 JVM 构建 exe,用户将只看到 exe 文件,但您的 JAVA 程序将启动并在内部 JVM 上运行,在这种情况下,您可以使用exe4j