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

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

问题描述

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



假设我想把它分发为一个可执行文件。我可以轻松地在一个文件(包括一些Ant黑客)中将应用程序和所有外部依赖关系构建为.jar。



现在假设我要将其分发为Windows上的.exe文件。这很简单,给了很好的工具(如Launch4j和喜欢)。



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



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

解决方案

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


Suppose I want to distribute a Java application.

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).

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).

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.

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)?

解决方案

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.

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

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