• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Running a jar file

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://java.sun.com/developer/Books/javaprogramming/JAR/basics/run.html
 
Rancher
Posts: 5077
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

Thanks,
Divith
 
They weren't very bright, but they were very, very big. Ad contrast:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic