This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Java in General and the fly likes Running a jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Running a jar file" Watch "Running a jar file" New topic

Running a jar file

Divith Shetty

Joined: Mar 17, 2008
Posts: 9

I have written some java program in which i am using some external jars. The code is running fine. I exported the jar as Runnable jar using the eclipse export option. I named the jar as abc.jar then i try to run it using "java -jar abc.jar". It started to execute but threw a exception java.lang.NoClassDefFoundError in between where i used the classes in the external jar, eventhough the refered jar files are there in classpath. Looks like classpath is getting reset to the current directory. I hope i am clear. Can anyone please help me resolve this issue.

Thanks in Advance
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 685
Please copy and paste full text of error message here.
To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'

Paste here.
Divith Shetty

Joined: Mar 17, 2008
Posts: 9
Hi Norm Radder,

I resolved the issue. Those external jars actually referring to some other jar. I think those jars where in the classpath thats why it was working when i run it from eclipse toolkit. But when i export my project as Runnable jar the manifest file will have an entry for classpath which points only to the current directory. So at run time my program wont find those additional jars. SO i also added those additional jars in my build path. That resolved the issue

I agree. Here's the link:
subject: Running a jar file