This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes Linux / UNIX and the fly likes java.lang.NoClassDefFoundError when running a jar file on Linux machine. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "java.lang.NoClassDefFoundError when running a jar file on Linux machine." Watch "java.lang.NoClassDefFoundError when running a jar file on Linux machine." New topic
Author

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

Mahita Ande
Greenhorn

Joined: Sep 26, 2012
Posts: 16
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

Joined: Sep 26, 2012
Posts: 16
Thank you, but, is there a way I can accomplish this without downloading JRebel.

-Mahita
Mahita Ande
Greenhorn

Joined: Sep 26, 2012
Posts: 16
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.NoClassDefFoundError when running a jar file on Linux machine.