如何将 JRE 与 Launch4j 捆绑在一起?
我的计算机上有 Launch4J,它是一个很棒的程序。我感兴趣的功能之一是能够将 JRE 捆绑到通用 .EXE 文件中。但是,我找不到任何描述如何执行此操作的文档。
如何将 JRE 与 EXE 捆绑在一起?另外,我从哪里可以获得一个紧凑、可移植的 JRE 来运行? Oracle 上的下载链接用于安装程序包。
I have Launch4J on my computer and it's a great program. One of its features I'm interested in is the ability to bundle a JRE in the general .EXE file. However, I can't find any documentation that describes how to go about doing this.
How do I bundle a JRE with the EXE? Plus, where do I get a compact, portable JRE to run? The download links on Oracle are for the installer packages.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
经过一番尝试,我终于找到了一种解决方法,将 jre 捆绑到我的应用程序中:
我将我的应用程序打包为 zip 文件,其中包含以下文件夹:
在 launch4j 的 xml 文件中,我像这样配置 jre:
这里的技巧是路径不是java.exe 文件。 jre 的路径是相对于 .exe 的位置,它应该指向 java.exe 文件之前的一个文件夹。
我使用的 jre 文件夹只是 Windows 系统上安装的 jre 文件夹的复制和粘贴。
After some attempts i finally get a workaround to bundle the jre in my application:
I package my app as a zip file with the following folders inside:
In the xml file of launch4j i configure the jre like this:
The trick here is that the path is not to the java.exe file. The path to the jre is relative to the position of the .exe and it should point to one folder before the java.exe file
The jre folder i'm using is just a copy&paste from the jre folder installed on a windows system.
我做了以下操作,它使用 ver Launch4j 3.11 对我有用:
我的应用程序)。
以及 lib 文件夹。
所以现在 MyApp 文件夹包含:
Files (x86)\Java\jre7) to MyApp\jre
在Launch4j中设置了所有必需的选项,然后设置
捆绑到“jre”的 JRE 路径
被选中。
I did the following and it worked for me using ver Launch4j 3.11:
MyApp).
along with the lib folder.
so now MyApp folder contains:
Files (x86)\Java\jre7) to MyApp\jre
In the Launch4j having set all the required options, then set the
Bundled JRE path to "jre"
is selected.
和你哥一样的问题。现在不用担心了。一切都以最大深度来解决,以解决未来的解决方案。
解决如何将 JRE 捆绑到 jar 中而无需用户安装 java 的问题。您的 Java 应用程序将运行。
lib
和bin
文件夹从 JRE 文件夹复制到项目 dist 文件夹技巧是您需要提供包含 javaw.exe 的完整路径。
享受!!!!
The same problem like you mate. No worries now. Its all solve with the maximum depth to solve future solution.
Solution how you can bundle your JRE for your jar without the need that the user has to install java or not. Your java application will run.
lib
andbin
folder from your JRE folder to your project dist folderThe trick is you need to give the full path to the including javaw.exe.
Enjoy!!!!
上面提到的答案对我不起作用。我正在使用 JDK 20。我做了什么:
一个简单的文件夹视图:
The mentioned answers above did not work for me. I am using JDK 20. What I did:
A simple folder view:
我刚刚做了这个。上面清楚的描述了捆绑jre的方法。
在这里,我只是分享一个我曾经奋斗过的经历。如果您想在通过launch4j创建wrapper exe后创建安装程序exe,请注意launch4j和jre的文件路径。这是我用来解决问题的路径:
launch4j、bin/jre、resources/bin/jre。
launch4j、bin 和 resources 处于同一级别。
I have just done this. Above clearly describe the method for bundling jre.
Here, I just share an experience that I have struggled. If you want to create an installer exe after created wrapper exe by launch4j, pay attention to the file path for launch4j and jre. This is my path I used to solve my issues:
launch4j, bin/jre, resources/bin/jre.
launch4j, bin, and resources are at same level.
jre 通常可以在您的 SDK 文件夹中找到。是的,在线链接是安装程序,但安装后,JRE 现在位于您的本地磁盘上。我的位于
您不需要的 JRE 部分,如果您确实需要,可以手动删除(我不确定网上有什么)。
The jre can usually be found in your SDK folder. Yes the links online are installers, but once it installs, the JRE is now located on your local disk. Mine is located in
The parts that you don't need from the JRE could probably be removed manually if you really wanted (I'm not sure whats available online).
使用 Launch4J 将 Java 应用程序与特定 JRE 捆绑在一起的工作示例可以在 https://github.com/vZome/vzome/blob/master/desktop/platform/windows/README.md。此特定发行版配置为要求 vZome 才能使用 < strong>捆绑的 JRE,而不是目标平台上找到的任何 JRE。
希望这有帮助。
A working example of using Launch4J to bundle a Java application with a specific JRE can be found at https://github.com/vZome/vzome/blob/master/desktop/platform/windows/README.md. This particular distribution is configured to require vZome to use the bundled JRE rather than any JRE found on the target platform.
Hope this helps.