Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Executable java file

 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Could you please tell me how to create an executable file for a java appliction.
step by step instruction are much appriciated.
thanks
 
Paul Zill
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you be a bit more specific?
if you just want to run a java app instead of typing it from the command line just create a shortcut and for target put in "<path to java>java <path to class file>TestApplication"
 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Heloo,
I mean if I want to give this the program to a person who doesn't know java. I should give him with an executable file. so that he can double click the icon and get the program to run
hope this is more specific
 
Paul Zill
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well then . . .
in windows you can create a batch file (.bat) which does the same thing as the shortcut.
The only problem would be is if the person has java installed and their environment variables set (like a JAVA_HOME, or the jdks' bin\ directory in the path).
You could circumvent this by also including the jdk with your application (it's about 46 mb for 1.4) and calling that one explicitly in your batch file.
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another possibility (more common) is the executable .jar file. An executable .jar file is simply a .jar file with an extra line in the manifest:
Main-Class: my.main.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....
One other 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.
 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the answers....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic