如果我有Java源文件(*.java)或类文件(*.class),如何将其转换为.exe文件?

我还需要一个安装程序。


当前回答

Java项目被导出为Jar可执行文件。当你想做一个java项目的。EXE文件,你可以做的是“转换”JAR到EXE(我说,我把引号之间转换,因为不是完全这样)。

从intelij你将只能生成罐子

尝试下面的例子:https://www.genuinecoder.com/convert-java-jar-to-exe/

其他回答

Launch4j

Launch4j is a cross-platform tool for wrapping Java applications distributed as jars in lightweight Windows native executables. The executable can be configured to search for a certain JRE version or use a bundled one, and it's possible to set runtime options, like the initial/max heap size. The wrapper also provides better user experience through an application icon, a native pre-JRE splash screen, a custom process name, and a Java download page in case the appropriate JRE cannot be found. – Launch4j's website

如果您需要将整个应用程序转换为本机代码,即EXE加dll,有ExcelsiorJET。我发现它工作得很好,并提供了捆绑JRE的替代方案。

编辑:这是在2010年发布的-该产品已不再可用。

I can be forgiven for being against converting a java program to a .exe Application and I have My reasons. the Major one being that a java program can be compiled to a jar file from A lot of IDE's. When the program is in .jar format, it can run in Multiple Platforms as opposed to .exe which would run Only in very limited Environment. I am for the Idea that Java Programs shoudl not be converted to Exe unless it is very neccesary. One can always write .bat files that runs the Java program while it is a jar file.

如果真的有必要将其转换为exe, Jar2Exe转换器可以默默地完成,也可以附加与主应用程序一起编译的库。

I would say launch4j is the best tool for converting a java source code(.java) to .exe file You can even bundle a jre with it for distribution and the exe can even be iconified. Although the size of application increases, it makes sure that the application will work perfectly even if the user does not have a jre installed. It also makes sure that you are able to provide the specific jre required for your app without the user having to install it separately. But unfortunately, java loses its importance. Its multi platform support is totally ignored and the final app is only supported for windows. But that is not a big deal, if you are catering only to windows users.

以我之见,JSmooth似乎做得相当不错。