Creating An Executable JAR File
A little intro about Executable JAR File
An executable .jar file is simply a .jar file with an extra line in the manifest:
Main-Class: MyPackageName.ClassName
When you double click on this .jar file, the applciation should launch(*)
However, an executable .jar file IGNORES the system CLASSPATH variable. You can specify a Class path in the manifest:
Class-Path: anotherJarFile.jar ..
Note the capitalization and hyphenation of "Class-Path" Also note that the elements listed are relative to the location of the .jar file and not relative to the current directory or anything else. Also note that the different elements are separated by spaces, not : or ;
---------------
(*) This is, of course, assuming that the JRE is correctly installed. Just include the distribution .exe with the application, and tell the client that if they don't have java already installed on the target machine, they will have to install it before running their program. I usually have the client open up a DOS prompt (or the equivelent) and type java -version. This double checks that java is installed and enables you/the user to verify that the required version is installed. There are ways to automate this for "dumb" users, but I gave my mother these instructions and she could follow them....
A wonderful tutorial that explains about Executable JAR File.
In the first example author has used a Swing Frame which opens a Frame Window. If you had NOT matched the file type then when you click the jar file zip application will open.
Our aim is to display the frame window when user clicks the jar file. To do this we got to set the file type to javaw
of "D:\Program Files\Java\j2re1.4.2_03\bin\javaw.exe"
How to do this?
Open Windows Explorer, tools\folder options\File Types tab and scroll down to jar file click "change" button "open with" dialogue box appears click "others..." button and select
D:\Program Files\Java\j2re1.4.2_03\bin\javaw.exe". give open and OK.
After completing the above procedure when you click the jar file you will see the "Frame Window".
NOTE:
An executable jar file is defaulted to run with the javaw command, not the java command. This means that you won't get a DOS prompt/whatever upon double clicking, and any System.out.prinln() messages (or the equivelent) will not show up. This includes even when the program is designed to take input from user at command prompt.
An executable .jar file is simply a .jar file with an extra line in the manifest:
Main-Class: MyPackageName.ClassName
When you double click on this .jar file, the applciation should launch(*)
However, an executable .jar file IGNORES the system CLASSPATH variable. You can specify a Class path in the manifest:
Class-Path: anotherJarFile.jar ..
Note the capitalization and hyphenation of "Class-Path" Also note that the elements listed are relative to the location of the .jar file and not relative to the current directory or anything else. Also note that the different elements are separated by spaces, not : or ;
---------------
(*) This is, of course, assuming that the JRE is correctly installed. Just include the distribution .exe with the application, and tell the client that if they don't have java already installed on the target machine, they will have to install it before running their program. I usually have the client open up a DOS prompt (or the equivelent) and type java -version. This double checks that java is installed and enables you/the user to verify that the required version is installed. There are ways to automate this for "dumb" users, but I gave my mother these instructions and she could follow them....
A wonderful tutorial that explains about Executable JAR File.
In the first example author has used a Swing Frame which opens a Frame Window. If you had NOT matched the file type then when you click the jar file zip application will open.
Our aim is to display the frame window when user clicks the jar file. To do this we got to set the file type to javaw
of "D:\Program Files\Java\j2re1.4.2_03\bin\javaw.exe"
How to do this?
Open Windows Explorer, tools\folder options\File Types tab and scroll down to jar file click "change" button "open with" dialogue box appears click "others..." button and select
D:\Program Files\Java\j2re1.4.2_03\bin\javaw.exe". give open and OK.
After completing the above procedure when you click the jar file you will see the "Frame Window".
NOTE:
An executable jar file is defaulted to run with the javaw command, not the java command. This means that you won't get a DOS prompt/whatever upon double clicking, and any System.out.prinln() messages (or the equivelent) will not show up. This includes even when the program is designed to take input from user at command prompt.
0 Comments:
Post a Comment
<< Home