Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes JVM: Could not find the main class. Program will exit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "JVM: Could not find the main class. Program will exit" Watch "JVM: Could not find the main class. Program will exit" New topic
Author

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

Andee Weir
Greenhorn

Joined: Sep 13, 2002
Posts: 12
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

Joined: Feb 04, 2002
Posts: 231
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

Joined: Dec 20, 2001
Posts: 3271
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.


SCJP Tipline, etc.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
...and don't forget the blank line at the end of the manifest file.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Andee Weir
Greenhorn

Joined: Sep 13, 2002
Posts: 12
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
 
subject: JVM: Could not find the main class. Program will exit