"Could not find the main class" error when executing a self-made Jar

Hi,

I'm new to jar creation, and just attempted to package my class files together with libraries using Ant.

I've managed to get the JAR file with MANIFEST.MF inside. The MANIFEST.MF is as below:

Manifest-Version: 1.0

Ant-Version: Apache Ant 1.6.5

Created-By: 1.5.0_08-b03 (Sun Microsystems Inc.)

Main-Class: mg.misc.GameGui

Class-Path: jchart2d-2.1.0.jar jcommon-1.0.8.jar jfreechart-1.0.4.jar swing-worker-1.1.jar

Inside the actual JAR file, I have a package called mg, and within mg, I have many sub-packages, and one of them is called misc, and the main class I want to run is in there. Moreever, all those libraries are outside mg

Can anyone spot any possible cause of the error? Many thanks.

[760 byte] By [cyaevana] at [2007-11-26 21:10:00]
# 1
did you add two linefeed to your manifest.mf file ?
java_2006a at 2007-7-10 2:46:14 > top of Java-index,Java Essentials,Java Programming...
# 2
> did you add two linefeed to your manifest.mf file ?Do you mean two blank lines at the end of the file? Yes, I did
cyaevana at 2007-7-10 2:46:14 > top of Java-index,Java Essentials,Java Programming...
# 3
add .class to your main class name
java_2006a at 2007-7-10 2:46:14 > top of Java-index,Java Essentials,Java Programming...
# 4
> add .class to your main class nameNo, it doesn't work. It is not supposed to have .class at the end according the tutorial I read.
cyaevana at 2007-7-10 2:46:14 > top of Java-index,Java Essentials,Java Programming...
# 5

sorry, the .class is not needed.

are you sure your GameGUI contains an entry main method ?

If so, try this instead

Manifest-Version: 1.0

Ant-Version: Apache Ant 1.6.5

Created-By: 1.5.0_08-b03 (Sun Microsystems Inc.)

Class-Path: jchart2d-2.1.0.jar jcommon-1.0.8.jar jfreechart-1.0.4.jar swing-worker-1.1.jar

Main-Class: mg.misc.GameGui

hth

java_2006a at 2007-7-10 2:46:14 > top of Java-index,Java Essentials,Java Programming...
# 6

Trying to guess the cause is a losing proposition. Post some small, self-contained, compilable, and executable code that illustrates the problem. Define the disk/directory structure of the involved classes, so that the code can be compared with the class locations. Eliminate anything that isn't needed to illustrate the problem from the post.

Alternatively, follow a good tutorial, starting with everything in one directory, verifying that it works, and then add complexity, verifying that everything still works after each incremental change.

ChuckBinga at 2007-7-10 2:46:14 > top of Java-index,Java Essentials,Java Programming...
# 7
Thanks. I've tried your suggestion but it seems a different order still doesn't do the trick.Fortunately, I gave a try to this: http://fjep.sourceforge.net/#instwhich works really well for me, just couples of clicks and I have a working JAR file. Recommended!
cyaevana at 2007-7-10 2:46:14 > top of Java-index,Java Essentials,Java Programming...