Subscribe to Dogstopper's Code Mania        RSS Feed
-----

Java Executables

Icon 10 Comments
One of the most common beginner questions that I hear from Java beginners is "How to make Java executable file". Well, there are several interpretations of this:

How do I make an executable Java program?
How do I make a native executable Java program?

The first question is easily answered using the built-in executable JAR option that Sun/Oracle provides:
http://download.orac...de/jar/jar.html
http://www.cs.prince...on/jar/jar.html

If you do it through an IDE like Netbeans or Eclipse, you can look at those specific ways to compile a Jar. In Eclipse, you click "File" then "Export". From there, just follow the instructions. In Netbeans, you simply have to run it an look in the /dist directory of your project.

However, these simply create JAR files which are executable on any platform. However, many Windows and MAC users like to have a native application that they can have an icon for and have a familiar extension (.exe for Windows). Now, there are many reasons to and not to do this, and I advise you to read here:
http://www.excelsior...ava-to-exe.html

For Windows, I found that the easiest free application to use that works quite well is Launch4J. IT is easy to use and produces Windows executables FROM an executable Jar file.

I don't use Mac, but I found an article here that looks like it will work, but no promises:
http://java.sun.com/...aLP/JavaToMac3/

Now, when developing and releasing Java programs, it is always good to release more than one version. ALWAYS release at least the JAR and then after that, you should include all your native executables. When using SourceForge like I do, there are options to specify what downloads are recommended for each Operating System. For example, if you visit my DICBrowser page from a Windows machine, the green Download button links to a .exe, whereas if you visit from Linux or mac or anything else, it links to the JAR. HOWEVER, there are alternative files to download as well.

That's all I have so far on executable files in Java. I hope it answers many questions!

10 Comments On This Entry

Page 1 of 1

KYA Icon

11 September 2010 - 01:11 PM
The title is a bit misleading. The first thing that came to mind was calling executable files from within Java, i.e. exec().
0

Dogstopper Icon

11 September 2010 - 01:18 PM
Better?
0

KYA Icon

11 September 2010 - 01:28 PM
Much clearer now. :)
0

gibson.nathan Icon

11 September 2010 - 01:40 PM
very informative. i have always wondered how to create a .exe from a jar. great to know that it isnt a huge pain to do.
0

Tom9729 Icon

12 September 2010 - 03:40 PM
This is a less ideal solution possibly, but you can also use the GCJ compiler to build native executables

http://www.dreaminco...vely-with-gcj/.
0

Dogstopper Icon

12 September 2010 - 06:44 PM
I did try to use that before and like your tutorial said, it hardly works for Swing...or Generics...or anything past 1.1

I do think it has potential, just not yet.
0

Tom9729 Icon

12 September 2010 - 07:10 PM
Pretty good read on GCJ being used for real stuff: http://www.linuxjour...om/article/7413
0

RandomlyKnighted Icon

11 May 2011 - 12:14 PM
So you can convert the jar file to an exe so people who have Windows users don't have to worry about having the correct JDK installed. What about Mac and Linux users? I have friends that use both and if I create my application to run on their computers won't they have to have the correct JDK installed?
0

Dogstopper Icon

11 May 2011 - 01:26 PM
I don't generally support Mac, and linux users should know enough to not be hassled by an "easy" app.
0

acll19 Icon

04 July 2011 - 12:20 PM
I appologize for posting this late, but I was looking for a way of how to make an installer for a java application when I bumped into your post. I did some googling and I found GlassWork, and it is pretty good, but I was expeting you could give me some hints there.
Thanks in advance.
0
Page 1 of 1

April 2014

S M T W T F S
  12345
6789101112
13141516171819
20 21 2223242526
27282930   

Recent Entries

Search My Blog

Recent Comments

0 user(s) viewing

0 Guests
0 member(s)
0 anonymous member(s)