2

Now, don't get me wrong, I am a very competent programmer, but when I program, I typically develop things for the web using scripting languages like JavaScript, PHP, Python, SQL, etc. If I want to develop Java software (I am relatively experienced in Java), how do I distribute it?

Is there any good way to package up Java software in a nice little executable, send it out, and have it run? Alternatively, is there any good way to package up Java in some sort of installer, and send it out to be installed and run?

Nick Anderegg
  • 1,006
  • 1
  • 12
  • 25
  • Well, you actually wrote the answer in one of the tags to your question. JAR files are Java Archives, and consist of a group of compiled java files (.class files). Assuming you have one with a main method inside of it, there is your executable. A user will need a JVM for their computer to run it though. – Jems Jan 29 '11 at 17:51
  • 1
    @jerms, most Java programs use library jars and then it gets complex. – Thorbjørn Ravn Andersen Jan 29 '11 at 17:55
  • I use quite a few libraries, which makes things extremely complicated. – Nick Anderegg Jan 29 '11 at 18:01

9 Answers9

4

I'm using Launch4J http://launch4j.sourceforge.net/ it will generate an .exe executable for Windows, if the targeted system don't have JVM, it will tell user to download and get JVM.

technomage
  • 525
  • 4
  • 14
3

You can package Java applications in so called jar-files using the jar tool or any competent Java IDE. These jar-files are self-contained and seldom need any installer.

These .jar files can easily be distributed and executed.

If you're used to web-development, you may also be interested in the Java Webstart technology.

Some links to get you started.

Community
  • 1
  • 1
aioobe
  • 413,195
  • 112
  • 811
  • 826
3

I have found two approaches to work well, depending on the needs of the end user.

1) Java WebStart - allows for central distribution and easy maintenance, but works best for online users. Require you to have a web site to locate the files - these days this is easy to do on the Google Application Engine.

2) Wrapping up the Java program in a single jar using one-jar, and then using jsmooth to generate an .EXE file which ensures Java is available, extracts the jar-file and invokes Java on it. This works well for users not always on the net, where you want the launch process to be transparent, but is less easy to upgrade than the webstart approach.

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347
2

I use Maven to handle all the dependencies of my projects and that way when you utilise Maven to build your projects they will compile into one nice executable jar that contains everything so you dont need to worry about getting all your third-party jars in the right place etc.

christophmccann
  • 4,181
  • 7
  • 42
  • 66
1

There are a couple of ways: one is to create an installer that allows your user to install and run it. For this you can take a look at NSIS.... or you can just use Java Web Start where your user can just click the link and launch your application.

limc
  • 39,366
  • 20
  • 100
  • 145
1

Here you will find a large set of options: Open Source Installers Generators in Java
It is very useful for the "naive" customer or user of your application, to make the installation process as painless as possible. Let them install whatever is needed, DBMS, JVM, JMF and additional options via one installer.

Costis Aivalis
  • 13,680
  • 3
  • 46
  • 47
1

You can also consider use one of the rich client platforms available for Java. The learning curve is probably a lot higher than just creating a jar file and ship it, but you will get a lot for free when it comes to distribution. (Think Eclipse with auto update through an update site).

Do a search for "Eclipse RCP" and "Netbeans RCP" and you'll find the two biggest contenders here. I also performed a serach for "eclipse RCP installer" and one of the hits seems interesting:

http://download.instantiations.com/RCPPackagerDoc/integration/latest/docs/html/gettingstarted/GenInstaller.html

Knubo
  • 8,333
  • 4
  • 19
  • 25
  • I might have to have a look at this because I already use Eclipse, and its whole jar creation process, well, completely and totally sucks. Something like this might be useful. – Nick Anderegg Jan 29 '11 at 18:09
  • IF you develop in Java and use lots of libraries, you should swallow some dependency tool pill. I use maven 2 and I'm quite happy with how much it can do for me. The learning curve for this one is also somewhat higher than just the regular jar stuff. – Knubo Jan 29 '11 at 18:35
  • I did some googling on how maven and eclipse RCP match, and I fear that it might not be a good match. I saw some articles stating that there are some work in the pipes for maven 3 and Eclipse RCP, but I did not look deep into this. – Knubo Jan 31 '11 at 12:43
1

I personally like izpack. It generates a jar file installer that you could wrap up in launch4j, supports things like windows specific shortcuts, is highly customisable through XML and hooks directly into ant.

OneJar is great for smaller stuff, but for larger programs or applications it's nowhere near as flexible and in my experience is rather slow.

Michael Berry
  • 70,193
  • 21
  • 157
  • 216
1

Hello you can make an installer for your application.

In the link below you will find a nice help about izpack installer.

http://www.imrantariq.com/blog/?p=89

Link below contains a detailed pdf to make installer with izpack.

http://www.imrantariq.com/blog/?attachment_id=112

cheers

Muhammad Imran Tariq
  • 22,654
  • 47
  • 125
  • 190