Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.lang.NoClassDefFoundError when running a jar file on Linux machine.

 
Mahita Ande
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I created a jar file for all the compiled files and added manifest.mf so the jar is executable. But, when I run this jar on Linux machine I get Exception in thread "main" java.lang.NoClassDefFoundError:Caused by: java.lang.ClassNotFoundException:.

my java and class files are in directory /dir1/dir2/dir3/dir4/src/comp/proj/mod.
schema for my project is com.proj.mod
I created a manifest file in /dir1/dir2/dir3/dir4 with Main-Class: ClassName and the file ends in a new line (I also tried Main-Class: package.ClassName).
I create a jar file with manifest file and src directory in /dir1/dir2/dir3/dir4. (I also tried creating a jar file for /dir1/dir2/dir3/dir4/src/comp/proj/mod along with manifest file).
Now when use java -jar command I get NoClassDefFoundError. I also tried java -cp /dir1/dir2/dir3/dir4/src -jar jarFile.jar, but that did not work either.
I suspect it has to do with the directory structure and the way the class is being looked at. But I am not able to figure out the right way.

Please advice on how I can have the jar file running.

Thank you,
Mahita
 
Mahita Ande
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, but, is there a way I can accomplish this without downloading JRebel.

-Mahita
 
Mahita Ande
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your replies. This issue was resolved without additional pluggins. Solution was to have the manifest file and the jar file within the src folder (at the smae level as the package) instead of outside it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic