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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Starting a Java Application 2

Status
Not open for further replies.

Jimguld

Programmer
Mar 4, 2003
26
0
0
DK
Hi I have made a little Java Application that I would like to run. I have compiled it and can run it using the

c\:> Java myapp

However I would like to run it from a desktop icon. So when I double click on an icon the application starts. How do I do this, and what command should I type in the fields of the properties in the icon.

Startin...
Target...
 
create a batch file called myjava.bat (extension has to be .bat).

in the file, type this (from your example above):-

java myapp


then using the bat file, you can create a icon and place it on the desktop.

(note: this is assumed that your classpath and environment is set up properly.)

the drawback to this approach versus running from the command prompt is, if there is any error, you won't be able to see since the command window will close itself automatically upon completion.

~za~
You can't bring back a dead thread!
 
you could also create a shortcut to java.exe that passes your file's name as an argument (this might not work in xp).
 
Once you've got the basics down, you should look into creating a self-executing jar file.

This is a jar file that contains the name of the class that contains main() in it's manifest file.

A free IDE like JDeveloper will create one of these from your application. It will also bundle all the other jar files your application uses into this one single jar so that no classpaths or external jar files are needed. This makes deployment to other computers easy.

Once this is done, you only need to create a shortcut to the jar file on your desktop and double-click it to start the application (In windows the file type "jar" has to be associated with javaw.exe).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top