File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jar executable

 
James Kerruish
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 54
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
James Kerruish
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
whoops, forgot the - infront of cp... i'm fine
SHaun
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic