tags:

views:

298

answers:

5

Is everybody thinking that everybody else doesn't release softwares as jar and then releases softwares as exe too?

+5  A: 

Yes. If you dealing with end users and not programmers, building a native solution for his platfrom is a good idea. Create a dmg, a exe and some linux packages. For exe stuff, take a look at launch4j or jsmooth.

Tim Büthe
We use jsmooth with ant, very nice when using a build server.
Thorbjørn Ravn Andersen
A: 

Depends on who your audience is. If you write applications intended to be installed by professional system administrators I would just do jars. If you are writing for end users without any technical knowledge, a system dependent binary might be the right choice.

When taking the jar route, I would consider building two distributions: one including all the libraries the application depends on and one without these.

As for the binary: why not supply a thin wrapper in the form of a batch file or shell script?

Jeroen van Bergen
+1  A: 

Another alternative is install4j,

a powerful multi-platform Java installer builder that generates native installers and application launchers for Java applications.

I have downloaded and installed an application which used it and it worked fine. However, its price may deter individuals or small companies trying to deploy a smallish Java application.

Yuval F
+14  A: 

Java software can be release in a number of ways depending on the target market.

The simplest for the developer (but hardest for the end user) is to just release a jar file (or set of Jar files). On many systems the JAR will be "double-click-able", and so act as an executable. But if the end user does not have Java installed it will not work.
Good if you control the target environment. Also good if you want to target Windows, Mac and Linux all at once. Any platform with Java can run it, including platforms you had not considered.
Bad if you are targeting normal users. It can not do "install tasks", set up anything in the start menu or associate itself with a file type.

Java Web Start is my preference in most cases. It gives a Java based installer and can set up the start menu, associate file types and all that goodness. But does bring up a security box on install.
Good for most cases. You have just the one link for all OSes.
Bad if you suspect the user does not have a JRE installed or you don't want the end user to be aware that the application is written in Java.

You could release a zip file with the Jars in and a .bat file and a .sh file to get the going.
Good for administrators, developers and command line applications.
Bad for end users who don't really know what a bat and shell script are and would have no idea what to do if the script was broken for their system.

A thin .exe wrapper round the Jar file. This gives the impression to the end user that the application is native. They normally come with...

A Java aware installer. This is a native installer (so different installers for Windows, Mac & Linux). This will be able to detect if the target machine has Java installed and if not be able to kick off the installation of the JRE. It will also be able to do all the fun post-install stuff such as setting file associations and add items to the start menu.
Good for most cases.
Bad if you are targeting multiply platforms as you will need to maintain an installer for each platform. Also bad if one of the target platforms does not have a Java aware installer (you will then need to use of of the other methods above for that one platform).

Native EXE. Using a Java-to-native compiler (Jet, GCJ or IKVM) you create a native executable.
Good if you really don't want people to know you are using Java or need to integrate with the native environment in some odd way (ikvm will let you use your Java code in .NET as simply a .NET object).
Bad as people think that this will magically make the application faster when it will not.

Edit: IKVM

mlk
+1 excellent summary of the available possibilities
Joachim Sauer
+1  A: 

You can do it yourself by writing a short (C ?) program like this:

//run tests here
system("java -jar my_file.jar");

But you will need to create a version of this executable for each Operating System.

Liran Orevi
`<parameters>` would need to go before `-jar` for JVM parameters, after the jar file for application parameters. Also, I would advise using some call other than `system`, at least if the user is allowed to specify parameters.
Michael E
And checking that a JRE is installed...
ShiDoiSi
True comment about the <parameters>, what kind of call would you recommend @Michael E ? Regarding extra functionality such as checking for... - it's not a full program, that is left for the actual programmer.
Liran Orevi