在 Windows 可执行文件中嵌入 JRE? [英] Embed a JRE in a Windows executable?

查看:34
本文介绍了在 Windows 可执行文件中嵌入 JRE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我想分发一个 Java 应用程序.

Suppose I want to distribute a Java application.

假设我想将它作为单个可执行文件分发.我可以轻松地在一个文件中构建一个包含应用程序及其所有外部依赖项的 .jar(使用一些 Ant 黑客技术).

Suppose I want to distribute it as a single executable. I could easily build a .jar with both the application and all its external dependencies in a single file (with some Ant hacking).

现在假设我想在 Windows 上将它作为 .exe 文件分发.考虑到现有的好工具(例如 Launch4j 等),这很容易.

Now suppose I want to distribute it as an .exe file on Windows. That's easy enough, given the nice tools out there (such as Launch4j and the likes).

但现在假设我也不想依赖安装了正确 JRE(或任何 JRE)的最终用户.我想用我的应用程序分发一个 JRE,我的应用程序应该在这个 JRE 上运行.创建 Windows 安装程序可执行文件并在其中嵌入一个包含所有必需 JRE 文件的文件夹非常容易.但后来我分发的是安装程序,而不是单文件应用程序.

But suppose now that I also don't want to depend on the end user having the right JRE (or any JRE at all for that matter) installed. I want to distribute a JRE with my app, and my app should run on this JRE. It's easy enough to create a Windows installer executable, and embed a folder with all necessary JRE files in it. But then I'm distributing an installer and not a single-file app.

有没有办法将应用程序 JRE 嵌入到一个 .exe 文件中,作为应用程序启动器(而不是安装程序)?

Is there a way to embed both the application, and a JRE, into an .exe file acting as the application launcher (and not as an installer)?

推荐答案

尝试使用 AvianProGuard 工具包.Avian 允许在您的应用程序中嵌入轻量级虚拟机.支持 Linux、MacOS、Windows 和 iOS.ProGuard 允许您缩小大型 jar 文件以准备嵌入.

Try to use Avian and ProGuard toolkits. Avian allows to embed lightweight virtual machine in you app. Linux, MacOS, Windows and iOS are supported. And ProGuard allows you to shrink large jar file to prepare to embed.

这篇关于在 Windows 可执行文件中嵌入 JRE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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