已在java.ese中打开,如何将JRE捆绑到Java应用程序的EXE中? Launch4j表示“运行时丢失或损坏。”...

I am new to programming in Java but am generally familiar with how everything works. I would like to be able to put both a jar file and a jre into a windows executable(exe) so that when I distribute it, the client needn't have a JRE installed. What program should I use?

I have launch4j and it seems to do exactly what I want but when I try to run the app, I get "This application was configured to use a bundled Java Runtime Environment but the runtime is missing or corrupted."

I want my app to just be a runnable exe, not an installer. At the very least, can anyone show me how to correctly bundle a JRE with launch4j?

解决方案

The only way I could bundle a JRE was to use Launch4J and Inno Setup Compiler.

First, create a jre6 folder (for example) in the same directory as your output file (.exe).

Then copy the JRE from your system into your jre6 folder.

Then you open Launch4J and set the Bundled JRE path - just type in jre6. Then click the Build button (obviously, after you've entered all the other parameters - but the only value you need to enter on the JRE tab itself is the Bundled JRE path value.)

I would have expected that to work, but if you then move the .exe to a new location (so it is no longer co-located with your jre6 folder) you get the This application was configured to use a bundled Java Runtime Environment but the runtime is missing or corrupted error when you try to run the application...

I've been playing around with this all day and there was no way I could get Launch4J to include the JRE in the .exe file. Really poor in my opinion, as their documentation does not seem to allude to this issue at all.

So what I did to solve was to use Inno Setup Compiler (ISC). This app is used to wrap your .exe as a Windows Installer file. So I added a setting to the ISC script that copies the JRE into the installer package. The line I added to the script (in the [Files] section) was:

Source: "M:\Netbeans\MyApp\jre6\*"; DestDir: "{app}\jre6\"; Flags: recursesubdirs createallsubdirs

...a bit of workaround, but it did the trick.

Repeat all the above steps, and you should be sorted.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值