3 Replies Latest reply on Jul 14, 2010 4:44 AM by 843810

    Exception in thread "main" java.lang.NoClassDefFoundError

      Just a little question regarding manifesting and creating .jar file.

      I have made a simple java program just to test how to manifest and create a .jar file. However, I came to a stage where I always get this error while I was trying to run the .jar file I had created.

      I could create, compile and run java without any problem, so there isn't any problem with my CLASSPATH. And I'm sure there aren't any problem with the java code either.

      I created a .java and compiled it into a .class.
      Next, I created a manifest.txt with the content:
      Main-Class: test
      I went to the command prompt (I'm using windows) and type as such, to create a test.jar.
      jar cvfm test.jar manifest.txt test.class
      So, the test.jar is created in the same directory as the manifest.txt and test.class.
      Next, I tried to run the test.jar:
      java -jar test.jar
      It gave me an error:
      Exception in thread "main" java.lang.NoClassDefFoundError: test/class
      I tried many times, recompile, checked my java code, checked the manifest file, recreated the .jar file, and try, and still get this error.

      Can anyone tell me what went wrong? and how to solve this error?