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

JVM: Could not find the main class. Program will exit

 
Andee Weir
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I've a problem that has been bugging me for ages. I've written a number of small Swing applications using Websphere Studio 4.0.2. When I run them in Studio they work fine. If I export them to a jar, together with the other classes & jars that they use, & select the class of the application entry point (in other words select the class that contains the starting main method) they appear to compile ok but when I run them I get the "Could not find the main class" error message.
Even more frustratingly the first ever Swing application I wrote (& based the remaining apps on) works fine.
Thanks for any help,
Andee
 
Juanjo Bazan
Ranch Hand
Posts: 231
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you trying to run it?
Which command are you using?
Do you have the proper manifest file inside your jar??
 
Corey McGlone
Ranch Hand
Posts: 3271
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andee,
Welcome to Javaranch
We'd like you to read the Javaranch Naming Policy and change your publicly displayed name (change it here) to comply with our unique rule. Thank you.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...and don't forget the blank line at the end of the manifest file.
 
Andee Weir
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your time Juanjo.
I'm running in WinNT by double clicking it from explorer. I've set Windows up to do java -jar xxxx.jar to jarfiles
I think I've got to the bottom of it. My jar file required other jars for it to work. I never managed to successfully package all these up into one jar but did the following instead:-
1) created my executable jar (manifest includes Main-Class: & also Class-Path: - this last one lists the location & names of the other jar files eg Main-Class: com.andee.MissingUtaRoles
Class-Path: lib/ldap.jar lib/jndi.jar lib/ldapbp.jar lib/ldap40.jar lib/ldapbp.jar)
2) place this executable jar file in a folder
3) created a subfolder of lib in the folder created in 2)
4) placed the required jars in folder 3)
5) double clicked the executable jar & it now works.
Andee
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic