File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes jar executable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "jar executable" Watch "jar executable" New topic
Author

jar executable

James Kerruish
Greenhorn

Joined: Aug 22, 2001
Posts: 16
I've managed to construct a jar file and things work fine from the command prompt when I type:
java -jar GraphNet.jar
I want to be able to run the jar file when I double click on it from within Windows NT. When I do so a box pops up requesting a program to open the jar file with. I select javaw.exe and the Java Virtual Machine comes up with an error saying:
Could not find the main class. Program will exit!
What am I doing wrong?
Thanks
James
Marcel de Jong
Ranch Hand

Joined: May 27, 2002
Posts: 54
James,
did you include a manifest file inside the jar?
Inside the manifest file you need to supply the main class. you put in the manifest file the class which need to be started.
For example:
Manifest-Version: 1.0
Created-By: 1.2.2 (Sun Microsystems Inc.)
Main-Class: foo.MainClass
Regards,
Marcel
Shaun Brierly
Greenhorn

Joined: Aug 22, 2001
Posts: 17
Hello,
This is a similar question, so I'll just use this topic instead of creating a new one.
I have my Jar working fine, however my Application needs to have some System Properties set, with the -D option. Anyone know how to do this, and still have it so you can simply double click the .jar in windows?
Thanks.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
We just have a .bat file that sets the classpath and invokes the application with the properties file as a parameter.
Then the user just double clicks an icon that points at the .bat file.


"JavaRanch, where the deer and the Certified play" - David O'Meara
James Kerruish
Greenhorn

Joined: Aug 22, 2001
Posts: 16
Yeah my manifest file is set up fine. I know this because the program runs when I type in the command prompt. I've also just tried the jar file on another machine and it works fine.
The problem seems to be somethings wrong with windows not associating the jar file with the specific program that is required to run it and therefore won't work when I double click on it.
Thanks for your help.
James
Vikas Varma
Greenhorn

Joined: Aug 21, 2002
Posts: 23
Originally posted by Shaun Brierly:

I have my Jar working fine, however my Application needs to have some System Properties set, with the -D option. Anyone know how to do this, and still have it so you can simply double click the .jar in windows?

If you are using Windows, the easiest way is to create a short-cut, and type the following in the target field
javaw.exe -DSYSPROP=system.properties -jar D:\Prog\Program.jar
One can easily avoid the command-prompt window.
--Vikas
Shaun Brierly
Greenhorn

Joined: Aug 22, 2001
Posts: 17
Thanks for the reply!
I made the shortcut, and javaw is located in windows\System32... ok so I added -cp {myclasspath}... However I'm still getting the class not found error... any ideas? Thanks

Shaun
Shaun Brierly
Greenhorn

Joined: Aug 22, 2001
Posts: 17
whoops, forgot the - infront of cp... i'm fine
SHaun
 
Consider Paul's rocket mass heater.
 
subject: jar executable
 
Similar Threads
Jar file accessing folder
executable jar file problem
Running a .exe from java program
using .exe in the .jar
Cannot run .jar file