0

Trying to create a windows executable but always get error on Exception in thread main java.lang.NoClassDefFoundError. I've read all the other responses but so far my issue remains the same. I have a class file called testproject that has a main procedure that is public static void. My class file also have a package designator at the top of the file called testproject. My class file compiles successfully into a file called testproject.class.

The command below works but when I run testproject.jar, I get the above error:

 jar cvfm testproject.jar c:\temp\manifest.txt *.class

Contents of manifest.txt:

 Main-Class: testproject.testproject

I've tried many combinations of Main-Class

Jav_Rock
  • 22,059
  • 20
  • 123
  • 164
  • 2
    first of all java has methods and not procedures, and secondly not providing code makes it imposible for someone to track down your problem – MaVRoSCy Sep 04 '12 at 18:59
  • Not really seeing how eclipse fits into all this, since your packaging the Jar yourself. Eclipse Export also does this for you. If your building this on the command line, check the spelling (Classes are Case sensitive, and usually begin with a capital letter) try java -cp testproject.jar testproject.Testproject – Mike Sep 04 '12 at 19:09

3 Answers3

0

please add the code that you have written in your java file.Otherwise it can not be tracked.

Biswajit
  • 2,434
  • 2
  • 28
  • 35
0

seems like the jvm is not able to find the class file for the Main class.the possible root causes could be

  1. The files are not generate at correct places ,Try extracting the jar file an see if the classes are there in correct package folders
  2. The Manifest file or the jvm command line classpath or the manifest file doesn't contain the entry for path to the class file
  3. Try using IDE for generating the JAR file , that usually helps
Akash Yadav
  • 2,411
  • 20
  • 32
0

It seems like you are executing the command "jar" from your package "testproject": jar -cvfm testproject.jar c:\temp\manifest.txt *.class

Try to execute it from parent folder: jar -cvfm testproject.jar c:\temp\manifest.txt testproject/*.class

The class file will be put into the "testproject" package.

By the way, be ensure that your manifest file has a new empty line at the end.

K_K
  • 41
  • 4