Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make a java program executable 1

Status
Not open for further replies.

fatcodeguy

Programmer
Feb 25, 2002
281
CA
Hi! I was wondering how I could make my program executable? Thanks
 
The best I've ever got (and that ain't saying much) is writing a simple batch file/shell script which then calls the "java Bla" from the command line prompt. Crude and crap, but it works. I've never been able to make an "executable" in the sense of a C++ executable.

As I understand it, this is in effect because java classes are not executable machine code - they are byte code created by the "javac" program. When you type "java Whatever" on the command line, or compile/run project in an IDE, the "java" program then interprets the byte code (class) into machine code on the fly - in effect creating the executable as it goes ... (This is why they say java is so portable)

I have however heard tell of the mystery of the 'self-extracting jar file'. When you create a packaged jar file using "jar -cvf myJarFile.jar C:\java\myproject", there is a way/ a tool/ some magic method of making this executable, but then this may just be myths and legend !

By the way someguy321, I've replied to enough of your threads today - give me a vote !!!!!!
 
yeah, I guess I can do that for you sedj!! Thanks for the help!
 
You can create an executable from a java program. While its not really a good idea to do, because you obviously lose the platform independence java provides, it can be done. Take a look at his thread: thread269-276852

-gc "I don't look busy because I did it right the first time."
 
You can do it in J++ I think. But I too usually make a batch file to call the javac [class file].
 
depends on what you want to do - do you want to launch it from the desktop? If so just create a shortcut and set it to run your application with javaw.
 
Hi
I had the same problem of making the Java application into a ".exe".
I was intending my application to run on Windows so i used a windows s/w called "Jexegen". This comes with the Micorsoft's Java SDK.
Try it out and hope it helps.
REGARDS
satish
 
I hope that you understand my limited english.
If you want to make your program executable only to be launched from the desktop you can create a jar file. This jar file must include all the classes you use. Besides you must use jar option -m in which you indicate the name of a file called "manifest". This "manifest" is a file that includes information about the jar file you want to create, so you have to write on it the name of your class in which your main metod. The contents of this file must be as follows:
Main-Class: Ej

Where Ej is name of the main file and VozEdit.jar the name of my jar file

Here you have the command lines I use in an aplication i have created:

jar -cmvf Manifest.txt VozEdit.jar Ej.class images
jar -uvf VozEdit.jar parser/*.class
jar -uvf VozEdit.jar objbasicos/*.class
jar -uvf VozEdit.jar objgraficos/*.class
jar -uvf VozEdit.jar objGUI/*.class
jar -uvf VozEdit.jar objutiles/*.class
jar -uvf VozEdit.jar org
jar -uvf VozEdit.jar javax

For more information look in the tutorial more about creating har files.

Remenber that you must have asociated the javaw.exe program with the jar files.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top