java - 如何将 Java 程序转换为 .exe 文件?

标签 java installation exe

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

我的程序还需要一个安装程序。

最佳答案

javapackager

The Java Packager tool compiles, packages, and prepares Java and JavaFX applications for distribution. The javapackager command is the command-line version.

– Oracle's documentation

javapackager 实用程序随 JDK 一起提供。除其他功能外,它还可以生成带有 -native exe 标志的 .exe 文件。

WinRun4J

WinRun4j is a java launcher for windows. It is an alternative to javaw.exe and provides the following benefits:

  • Uses an INI file for specifying classpath, main class, vm args, program args.
  • Custom executable name that appears in task manager.
  • Additional JVM args for more flexible memory use.
  • Built-in icon replacer for custom icon.
  • [more bullet points follow]

– WinRun4J's webpage

WinRun4J 是一个开源实用程序。它具有许多功能。

packr

Packages your JAR, assets and a JVM for distribution on Windows, Linux and Mac OS X, adding a native executable file to make it appear like a native app. Packr is most suitable for GUI applications.

– packr README

packr 是另一个开源工具。

JSmooth

JSmooth is a Java Executable Wrapper. It creates native Windows launchers (standard .exe) for your java applications. It makes java deployment much smoother and user-friendly, as it is able to find any installed Java VM by itself.

– JSmooth's website

JSmooth是开源的,有特色,但是很老了。最后一次发布是在 2007 年。

JexePack

JexePack is a command line tool (great for automated scripting) that allows you to package your Java application (class files), optionally along with its resources (like GIF/JPG/TXT/etc), into a single compressed 32-bit Windows EXE, which runs using Sun's Java Runtime Environment. Both console and windowed applications are supported.

– JexePack's website

JexePack 是试用软件。生产使用需要付费,使用该工具创建的exe文件在不付费的情况下会显示“提醒”。此外,最后一次发布是在 2013 年。

InstallAnywhere

InstallAnywhere makes it easy for developers to create professional installation software for any platform. With InstallAnywhere, you’ll adapt to industry changes quickly, get to market faster and deliver an engaging customer experience. And know the vulnerability of your project’s OSS components before you ship.

– InstallAnywhere's website

InstallAnywhere 是一个商业/企业软件包,可为基于 Java 的程序生成安装程序。它可能能够创建 .exe 文件。

可执行 JAR 文件

作为 .exe 文件的替代方案,您可以创建双击时自动运行的 JAR 文件,方法为 adding an entry point to the JAR manifest .

<小时/>

了解更多信息

有关此主题的优秀信息来源是这篇文章“Convert Java to EXE – Why, When, When Not and How”,作者:Dmitry Leskov

另请参阅配套页面“Best JAR to EXE Conversion Tools, Free and Commercial

关于java - 如何将 Java 程序转换为 .exe 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33528544/

相关文章:

java - 使用 Math.random() 的表达式总是返回相同的值

java - 在 Vim 中编码 java 时,如何在编辑时直接在 vim 中显示代码输出

delphi - 如何添加设置并进行设置,然后将其内置到Delphi中的现有exe文件中

java - FastVector<E> 类型已弃用

java - 从 Angular 解析日期

exception - 关于通过防火墙扩展在 wix 安装程序中添加防火墙异常的问题

installation - 使用 WiX 和 MSI 进行多产品共享组件设置?

php - 在 Magento 安装期间哪些文件被更改

python - 如何将python文件转换为可执行文件?

python - pyinstaller multipackage错误(MERGE方法)