问题描述
如果你有一个小程序,你可以运行jar文件,它会正常工作。但是如果你将jar文件转换为exe文件,你仍然需要java来运行你的exe文件,那么它们之间有什么区别?为什么有些人将jar转换为exe文件?
If you have a small program, you can run jar file and it will work fine. But if you convert jar file into exe, you still need java to run your exe file, so what's the difference between them and why do some people convert jar to exe?
推荐答案
表面上,EXE是一个可执行程序,它启动本地java来执行bundle类。
An EXE is, ostensibly, an executable program that launches the local java to execute the bundle classes.
你可能知道,在计算机上,您可以将某些文件扩展名与本地程序相关联。例如,带文字处理程序的 .doc
文件。
As you may know, on your computer you can associate certain file extensions with local programs. For example, .doc
files with your word processor.
同样, .jar
文件可以与Java相关联,以便Java可以执行它们。如果jar文件中包含所有必需的类,并且指向启动类的正确清单,那么jar文件被认为是独立。
Similarly, .jar
files can be associated with Java, so that Java can execute them. The jar file is considered "stand alone" if it has all of the necessary classes bundled within it, and a proper manifest pointing to the startup class.
因此,通过关联 .jar
使用Java,在您的环境中单击它将使用给定的jar文件启动Java。
So, by associating .jar
with Java, clicking on it in your environment will launch Java with the given jar file.
一个EXE不需要那种联想。它通过它自己的启动器找到java。
An EXE doesn't need that association. It find java on its own with it's own launcher.
下一步是你可以将JRE捆绑到一个EXE中,所以你甚至不需要让用户安装Java作为先决条件。但这是一个不同的过程。
The next step is that you can actually bundle the JRE in to an EXE, so you don't even need to have the user install Java as a pre-requisite. But that's a different process.
这篇关于运行jar文件和exe之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!