开发者

Distribute my application jar with a JRE

How can I distribute my application jar with JRE? I make my executable jar in exe by using launch4j.

My application is a desktop based swing application. I want to make it like an application that if the user has no JRE installed, they can use it by using the embedded JRE. I give JRE with the application and use it. Uninstallation of the application and JRE will uninstall like games.

I understand that if I give the pre-installed JRE with my application, it will happen. I also see the tab JRE in launch4j, but I do not understand which path I will give. This link I also see, but there is no procedure or helpful link is given where the total procedure is defined clearly.

Please give some definite answer. I will prefer if your answer i开发者_运维技巧s based on launch4j.


How do you distribute your application? Do you have an installer?

If you do have a installer, you could bundle any jre with it and configure launch4j to use it.

What I did to recreate your use case:

  1. Create a directory, e.g. C:\temp Copy my jdk from C:\Program Files\Java\jdk1.6.0_23 to C:\temp\myownjdk1.6.0_23 Configure
  2. launch4j to use my JDK: In the JRE tab, enter "myownjdk1.6.0_23" as
  3. Bundled JRE path and I configured to "Only use private JDK runtimes" - although I am not sure if that's really necessary.

I used a JDK, but I'm sure you can do the same with a JRE. Also, I am pretty sure that you must (or can) use relative paths for your bundle (like I did).

This is my configuration file:

<launch4jConfig>
  <dontWrapJar>false</dontWrapJar>
  <headerType>gui</headerType>
  <jar>C:\temp\demoapp.jar</jar>
  <outfile>C:\temp\thing.exe</outfile>
  <errTitle></errTitle>
  <cmdLine></cmdLine>
  <chdir></chdir>
  <priority>normal</priority>
  <downloadUrl>http://java.com/download</downloadUrl>
  <supportUrl></supportUrl>
  <customProcName>false</customProcName>
  <stayAlive>false</stayAlive>
  <manifest></manifest>
  <icon></icon>
  <jre>
    <path>myownjdk1.6.0_23</path>
    <minVersion></minVersion>
    <maxVersion></maxVersion>
    <jdkPreference>jdkOnly</jdkPreference>
  </jre>
</launch4jConfig>


A better strategy is to launch the app. using Java Web Start. Use deployJava.js to ensure a suitable minimum version of Java is available. The user might already have a suitable JRE installed (so no download needed), and will have it there for other Java applications and applets once they choose to uninstall the app.

This does not fit some of your stated requirements, but it is overall a superior option.


You can also check out BitRock InstallBuilder.

We provide very good support for Java - both detecting if it exists as well as easy inclusion of JRE and building a launcher binary.

You can find more information here: http://installbuilder.bitrock.com/docs/installbuilder-userguide/ar01s17.html#_bundling_a_jre

And Java component/JRE files: http://installbuilder.bitrock.com/java/

With the files from link above, it is as simple as setting a few variables in your project and the installer will work.

It is not free, but if your project is open source, you can apply for a free open source license you can use for creating installers for your application.

Disclaimer: I am one of developers of BitRock InstallBuilder, so I am biased.


I have created my own version of the launch4j that allows downloading and installing of required JRE automatically - unattended - (it shows progress for downloading, no progress for installing yet and no option to download the JRE installer to other directory than the installer's working directory - I can add this functionality if anyone is interested in it). Just go to launch4j's "JRE" tab to set your options. Also, this is only for GUI installation and not for console for now. Here you can get it: https://github.com/maztan/launch4j_auto_jre_download

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜