tags:

views:

126

answers:

6

i have a really basic java program just one .java/.class file (.java uncompiled .class compiled i guess) how do i make something that i can have run on someone elses computer?

A: 

You can use a tool like IzPack2exe. Even if you package the the program just as a jar file - double clicking it in windows win run it, if the user has Java installed.

Bozhidar Batsov
what about .jar files on a mac?
David
For mac you have this - http://izpack.org/documentation/izpack-utils.html#mac-os-x-application-bundle-wrapper-izpack2app
Bozhidar Batsov
+1  A: 

There are tools like NativeJ that will let you bundle a JRE, but obviously your executable is going to be much larger if you do that. Usually Java programs are just distributed as JAR files, which are just zip archives of the class files with a manifest

Michael Mrozek
A: 

For Java you usually build a jar file. You can simply execute it by double-clicking on it. It's basically a Zip file with some metadata and another name (yes, zip files don't have enough names already). Check out the jar tool that comes with your JDK. A Java IDE should also have the option to create such a thing.

Joey
+1  A: 

Have a look at the answers on this question.

Leonardo
+3  A: 

This sort of kills the very purpose of Java (portability of the language), so you should always try to use the files compiled as .jar, since most of the computers out there (especially Windows and Macs) do have a Java Virtual Machine.

If you really need to compile something down to exe, you should be interested in Ahead-of-Time compilers (AOT), one of them being the GNU Compiler for Java.

Bogo Giertler
A: 

You can also use NSIS. You can find an example of slightly better application launcher.

baris_a