Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
153 views
in Technique[技术] by (71.8m points)

How to deliver my Java application with a particular JRE?

Does somebody know how to pack a particular JRE together with a compiled Java application? I currently have an executable jar file and wish to put JRE 6 Update 31 in it. So that the application uses the shipped JRE regardless of which JRE version the client has installed. The solution should work platform independent.

Any ideas? Many thanks in advance!

question from:https://stackoverflow.com/questions/13045719/how-to-deliver-my-java-application-with-a-particular-jre

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

On OSX, they are moving away from Apple providing Java to Oracle providing Java, this also means that Java will not be installed on a fresh install of OSX. Oracle have provided a tool for packing up Java installations and they strongly recommend providing a jre as part of your installation. The advantage of this is that the customer will not have to install an additional package in order to run your application, and you can test your application against the correct Java runtime for you and ensure there are no incomptabilities before shipping. The disavantage is that building the installer is slighty more complex and your download size is larger.

Of course building installers get more complex if you want to provide your applications for Windows, Linux ectera and it would be alot simpler to just provide an executable jar but this is not the experience customers want. Customers do not expect to be able to download one application and run the same exe on windows, osx and linux. They are happy
to have different installers for each platform and also expect the installers to work in a different way.

This is how I do it:

OSX:Use AppBundler with bundled jre, put onto a Dmg with DMGCanvas. The user simply drags the application to their /Application folder.

Windows:Use Izpack with bundled jre wrapped with launch4j so installer can be run as an exe.

Linux:Use Izpack without bundled jre, as user linux users like to be in control of exactly what on their machine, but specify minimum version of Java allowed. Ideally I should create packages for the main Linux Package Managers such as rpm but Ive decided this is not worth the effort at the moment as Linux users are a small percentage of my client base.

Most of the installation is automated using Maven and Ant, so its not a big effort to build these different installers.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...