Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NoClassDefFoundError running a jar file from the command line

 
M Burke
Ranch Hand
Posts: 406
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I made a jar file I want to execute on the command line. It has jar dependanies, so the other jars are packaged inside my main jar file in the \lib directory.

So I try to execute like this...>java -jar mainjar.jar
and I get a NoClassDefFoundError on all the depedancy jars.

I edit the manifest.mf to add the class path and executable main like this...
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: 10.0-b22 (Sun Microsystems Inc.)
Main-Class: com.GenerateReports.test.TestCharts
Class-Path: lib\Generate.properties lib\jar1.jar lib\jar2.jar lib\jar3.jar



What am I missing?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't put the sub-jars inside the main jar; the class-path attribute refers to files outside of the main jar. The standard Java classloader does not have any idea how to load a jar inside a jar.
 
M Burke
Ranch Hand
Posts: 406
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, I see. That is too bad, it would make deployment easier. Thanks for your help.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
M Burke wrote:Oh, I see. That is too bad, it would make deployment easier.


I agree, and I think many people do!
 
Rob Spoor
Sheriff
Pie
Posts: 20751
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe enough people will complain so Sun will rewrite the system class loader to handle JARs in JARs. Don't expect it though.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic