• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jar executable

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
whoops, forgot the - infront of cp... i'm fine
SHaun
 
reply
    Bookmark Topic Watch Topic
  • New Topic