"Could not find the main class" when running a jar

Hi, I'm trying to create and run a jar from my application, but I can't figure out how to properly set an entry-point. Looking at the Java Tutorials http://java.sun.com/docs/books/tutorial/deployment/jar/index.html I still can't get it to work.

I have a directory myApp, which contains a directory images and some class files, including mainClass.class. I also have a manifest Manifest.txt in the directory myApp with the following line:

Main-Class: mainClass.class

+ one empty line

I create a jar successfully, while inside the myApp directory, with the following command:

jar cfm myApp.jar Manifest.txt *.class images\*.*

I then proceed to run the jar with the following command:

java -jar myApp.jar

and receive the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: myApp/class

My completely uneducated guess is that there is something wrong with my manifest. The tutorial says that the line should be:

Main-Class: MyPackage.MyClass

I'm assuming that I get the error because I didn't specify a package, which I didn't do because I didn't know what to put there. Do I even have a package?

Can anyone tell me what I've done wrong? thanks.

Message was edited by:

SmurfZG

[1301 byte] By [SmurfZGa] at [2007-11-26 12:28:55]
# 1

One problem is you are specifying a file name instead of a class name. It probably should beMain-Class: mainClassA good test is to run your app before jaring it - if you run it with "java mainClass" then the Main-Class attribute must be mainClass.

Also class naming conventions say that class names should start with a capital letter - MainClass for example. It is just a convention, but it is easier to get help when you follow conventions.

atmguya at 2007-7-7 15:37:54 > top of Java-index,Desktop,Deploying...
# 2
thanks! works like a charm.I do try to use the naming conventions, and the real class does use capital letters. I just didn't bother to make sure I had named my pseudo classes properly, but I'm sure to do it next time :p
SmurfZGa at 2007-7-7 15:37:54 > top of Java-index,Desktop,Deploying...