问题描述
我正在尝试使用launch4j将JRE捆绑到我的exe中。
我的文件夹结构如下 -
| - 测试
| - jre(从我的windows安装jre复制)
| -bin
| -lib
| - jretest.jar(我用来创建我的exe的jar文件)
| - jretest.exe(输出exe文件)
在Launch4j中,我将捆绑的JRE路径
设置为 jre
。
到目前为止exe工作正常。
然而,当我将我的exe文件复制到别处并运行时,我收到错误消息此应用程序配置为使用捆绑的Java运行时环境,但运行时丢失或损坏
。
任何想法可能会出现问题jre捆绑在里面?
我如何制作一个独立的exe?
我不想做一个我的应用程序的安装程序,但只是打算运行它。
任何帮助将不胜感激。
使用launch4j,不可能将JRE放在exe中。 launch4j的'bundle'选项只是意味着你将你的exe与JRE一起分发,以及它。您可以通过在config xml文件中添加以下选项来完成此操作。
< jre>
< path> .....< / path>
< / jre>
指定JRE相对于可执行文件的路径非常重要,否则它将无法工作如果您将exe移动到另一个位置(或另一台计算机)。您收到的错误消息是因为您没有将JRE与您的exe一起移动或复制,因此可执行文件无法再找到JRE。
或者如果您不使用bundle选项,launch4j将尝试使用系统JRE,如果找不到一个重定向用户到Oracle JRE下载页面。如果这不是您想要的,并且您真的想要一个exe用于分发,那么您唯一的另一个选择是使用NSIS或Inno Setup等安装程序。
I'm attempting to bundle the JRE into my exe using launch4j.
My folder structure is as follows-
|- test
|- jre(copied from my windows installation of jre)
|-bin
|-lib
|- jretest.jar (the jar file I am using to create my exe)
|- jretest.exe (the output exe file)
In Launch4j, I have set the Bundled JRE Path
as jre
.
The exe works fine so far.
However, when i copy my exe file elsewhere and run it, I get the error message This application was configured to use a bundled Java Runtime Environment but the runtime is missing or corrupted
.
I have searched on SO and found the following questions but couldn't get my application to work with the suggestions given there.
How to bundle a JRE with Launch4j?
Any idea what could be going wrong here with a jre bundled in it?
How can I make an independent exe ?
I do not want to make an installer for my application but just intend to run it.
Any help would be greatly appreciated.
With launch4j it's not possible to put the JRE inside an exe. The 'bundle' option of launch4j simply means that you distribute your exe together with a JRE, so alongside it. You can do this by adding the following option to your config xml file.
<jre>
<path>.....</path>
</jre>
It's important that you specify the path to the JRE relative to your executable, otherwise it won't work if you move the exe to another location (or to another computer). The error message you got is because you didn't move or copy the JRE together with your exe, so the executable can't find the JRE anymore.
Alternatively if you don't use the bundle option, launch4j will try to use a system JRE and if it cannot find one redirect users to the Oracle JRE download page. If this is not what you want, and you really want a single exe for distribution then your only other option is to use an installer like NSIS or Inno Setup.
这篇关于使用Launch4J将JRE捆绑到exe中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!