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

我还需要一个安装程序。


当前回答

你可以用Janel。最后一个是作为应用程序启动器或服务启动器(可从4.x获得)。

其他回答

注意:自第一次提出这个问题以来,打包和部署已经发生了很大变化。给出的大多数答案甚至都不是JIGSAW (Java 9+)的最新版本。

如果目标是创建特定于操作系统的包,Oracle Docs Java 17打包工具用户指南中提供了相关信息。本指南包括jpackage工具的文档,该工具允许为Linux、macOS和Windows创建特定于平台的包。我认为Windows特定的指令应该包括生成.exe文件,因为这仍然是Windows用户安装和运行应用程序最熟悉的方式。

My own personal experience creating an exe (for sale on itch.io) was with the Java Platform, Standard Edition Deployment Guide, which included making use of the tool Inno Setup 5. This documentation is older, is for Java 9. The section directly pertaining to .exe packaging is located here As a first step, I used jlink to make a self-contained package. At the time I was first wrangling with this, I was unable to figure out how to get jpackage to work with my modular program. But now that Jigsaw has been around for several years, jpackage is now likely much easier to use, and would be my first choice for the next Java app I might publish for Windows users.

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

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

我们正在使用Install4J为windows或unix环境构建安装程序。

它很容易定制,直到您想要为标准对话框无法完成的特殊操作编写脚本。但是即使我们用它来设置windows服务,我们也只是使用标准组件。

安装程序+启动程序 Windows或Unix Java脚本 ant任务 大量可定制的标准面板和操作 可选地包括或下载JRE 还能启动Windows服务吗 多种语言

我认为Launch4J来自同一家公司(只有启动器-没有安装程序)。

PS:很遗憾我没有得到这个代言的报酬。我只是喜欢那个工具。

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似乎做得相当不错。