如何将我的 Java 程序转换为 .exe 文件? [英] How can I convert my Java program to an .exe file?

查看:39
本文介绍了如何将我的 Java 程序转换为 .exe 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

解决方案

javapackager

<块引用>

Java Packager 工具编译、打包和准备 Java 和 JavaFX 应用程序以进行分发.javapackager 命令是命令行版本.

——Oracle 的文档

javapackager 实用程序随 JDK 一起提供.它可以生成带有 -native exe 标志的 .exe 文件,等等.

WinRun4J

<块引用>

WinRun4j 是一个用于 Windows 的 Java 启动器.它是 javaw.exe 的替代品,具有以下优点:

  • 使用 INI 文件指定类路径、主类、vm args、程序 args.
  • 出现在任务管理器中的自定义可执行文件名称.
  • 额外的 JVM 参数,可更灵活地使用内存.
  • 自定义图标的内置图标替换器.
  • [更多要点如下]

– WinRun4J 的网页

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

packr

<块引用>

打包您的 JAR、资产和 JVM,以便在 Windows、Linux 和 Mac OS X 上分发,添加一个本机可执行文件,使其看起来像本机应用程序.Packr 最适合 GUI 应用.

——打包自述文件

packr 是另一个开源工具.

JSmooth

<块引用>

JSmooth 是一个 Java Executable Wrapper.它为您的 Java 应用程序创建本机 Windows 启动器(标准 .exe).它使Java部署更加流畅和用户友好,因为它能够自己找到任何已安装的Java VM.

– JSmooth 的网站

JSmooth 是开源的,有功能,但是很老了.最后一次发布是在 2007 年.

JexePack

<块引用>

JexePack 是一个命令行工具(非常适合自动脚本编写),它允许您打包 Java 应用程序(类文件),以及可选的资源(如 GIF/JPG/TXT/等), 到一个 压缩 32 位 Windows EXE,它使用 Sun 的 Java 运行时环境运行.支持控制台和窗口应用程序.

– JexePack 的网站

JexePack 是试用软件.生产使用需要付费,使用此工具创建的exe文件会显示提醒"无需付款.此外,上一次发布是在 2013 年.

InstallAnywhere

<块引用>

InstallAnywhere 使开发人员可以轻松地为任何平台创建专业的安装软件.使用 InstallAnywhere,您将快速适应行业变化,更快地进入市场并提供引人入胜的客户体验.并在发货前了解您项目的 OSS 组件的漏洞.

– InstallAnywhere 的网站

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

可执行的 JAR 文件

作为 .exe 文件的替代,您可以创建一个双击时自动运行的 JAR 文件,通过 向 JAR 清单添加入口点.


了解更多信息

Excelsior 的文章是有关此主题的极好信息来源ConvertJava 到 EXE – 为什么、何时、何时不以及如何".

另见配套文章免费和商业的最佳 JAR 到 EXE 转换工具".

If I have a Java source file (*.java) or a class file (*.class), how can I convert it to a .exe file?

I also need an installer for my program.

解决方案

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

The javapackager utility ships with the JDK. It can generate .exe files with the -native exe flag, among many other things.

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 is an open source utility. It has many features.

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 is another open source tool.

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 is open source and has features, but it is very old. The last release was in 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 is trialware. Payment is required for production use, and exe files created with this tool will display "reminders" without payment. Also, the last release was in 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 is a commercial/enterprise package that generates installers for Java-based programs. It's probably capable of creating .exe files.

Executable JAR files

As an alternative to .exe files, you can create a JAR file that automatically runs when double-clicked, by adding an entry point to the JAR manifest.


For more information

An excellent source of information on this topic is Excelsior's article "Convert Java to EXE – Why, When, When Not and How".

See also the companion article "Best JAR to EXE Conversion Tools, Free and Commercial".

这篇关于如何将我的 Java 程序转换为 .exe 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆