开发者

What is the best way of packaging Java software for running on Windows?

What's the best way to package Java software for running on Windows? Is there a standard for writi开发者_运维问答ng .BAT files which can discover the latest installed JRE on the machine? Are there any Maven plugins for this? What's the deal with executable Jar files?


I would without any doubt recommand you to use Java Web Start, as it allows you easy control over version used (and by far the easier to use update mechanism available nowadays).


Depends on what you need.

We've found that using the One-JAR + JSmooth gives a very good user experience as it allows us to distribute a single EXE-file which can be put anywhere on the users system, as opposed to having installation binaries, which need to be installed and uninstalled etc. etc. etc. JSMooth checks for the existance of the appropriate Java runtime, and redirects to the official download site if none is found.

The reason for One-jar is that you generally need to use library jars which is best to have separately but JSmooth only allows for a single jar file.

Also the One-Jar SDK and JSmooth is scriptable without being tied to Windows, so we can build new versions on our Hudson engine running on Linux.


In the past I've used a java installer package like launchForJ. However, a lot of these packages use Java so you may need to a batch or simple executable written in native windows code that does a quick check to see if Java is already installed then run the installer.

Since Java uses system variables during install you should be able to check if the version (or higher) that you require exists in this way.


The standard way would be to use Java Web Start.

Using Java Web Start technology, standalone Java software applications can be deployed with a single click over the network. Java Web Start ensures the most current version of the application will be deployed, as well as the correct version of the Java Runtime Environment (JRE)

Maven has a Webstart Maven Plugin to help building application bundles that can be deployed via Web Start.

An alternative solution would be to use a cross-platform installer generator to generate, well, an installer. I personally like IzPack (I think that JSmooth is very similar but I have more experience with IzPack) and, if you are specifically targeting the Windows platform, you could use IzPack to Build [a] Native Windows Installers with IzPack Native Launcher:

A problem still arise with IzPack when the target system does not have a JRE installed. The user needs to first install it and then run the IzPack installer. This is not a problem with Linux or BSD users since they are generally skilled and they know how to do that by hand or with a packaging system (RPM, DEB, ebuilds, ports, ...). Similarly, a Mac OS X user will not have much problems since it is available with the operating system. However the situation is more complicated on the Windows platform as a JRE must be installed. Worse, several instances can be installed in a sometimes messy situation.

The IzPack Native Launcher tries to solve this problem. It is a C++ native application that is available under the very permissive MIT License and that uses wxWidgets for the GUI. It is thus cross-platform (for the historians: it was first developed on a FreeBSD box), but most people will need it on Windows. It uses a simple configuration file and will first check for a JRE. If none can be found, it will pop-up a dialog to let the user choose between the following options:

  • manually specify a JRE location
  • download one from the Internet
  • install one that is provided by the packager (if available).

IzPack also offers a Maven Plugin. Worth the check.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜