What's the best way to distribute Java applications?

Laplie Anderson picture Laplie Anderson · Sep 17, 2008 · Viewed 61k times · Source

Java is one of my programming languages of choice. I always run into the problem though of distributing my application to end-users.

Giving a user a JAR is not always as user friendly as I would like and using Java WebStart requires that I maintain a web server.

What's the best way to distribute a Java application? What if the Java application needs to install artifacts to the user's computer? Are there any good Java installation/packaging systems out there?

Answer

Noel Grandin picture Noel Grandin · Sep 17, 2008

There are a variety of solutions, depending on your distribution requirements.

  1. Just use a jar. This assumes that the user has the the correct java version installed, otherwise the user will get "class-file format version" exceptions. This is fine for internal distribution inside a company.

  2. Use launch4j and an installer like NSIS. This gives you a lot more control, although the user can still do stupid stuff like un-installing the java runtime. This is probably the most popular approach, and what I currently use.

  3. Use Webstart. This also assumes that the user has the correct java version installed, but it's a lot easier to get going. My experience is that this is fine for tightly controlled intranet environments, but becomes a pain with larger deployments because it has some many weird failures. It may get better with the new plug-in technology in Java 1.7.

  4. Use a native-code compiler like Excelsior JET and distribute as a executable, or wrap it up in an installer. Expensive, and it generally ties you to a slightly older version of java, and there is some pain with dynamic class-loading, but its very effective for large-scale deployment where you need to minimise your support hassles.