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/55051594/

相关文章:

java - 将按钮半径设置为主题

java - slf4j 和 log4j 日志消息在控制台中可见,但未附加到日志文件中

在 Windows 7 中安装 Sourcetree 时出现 Javascript 加载错误

angular - 有没有办法从 Angular 文件制作 .exe 文件?

java - MVVM MediatorLiveData观察者onchanged被调用多次

java - Maven cxf-codegen-plugin 不生成源码

node.js - 什么是测试文件?为什么它们包含在 Node.js 安装程序中,而不包含在二进制文件中?

Windows 安装程序 : can two different installer share the same componet

Java 代码,安全

ruby - 在未安装 ruby​​ 的计算机上运行 ruby​​ 程序