• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

NoClassDefFoundError running a jar file from the command line

 
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Sheriff
Posts: 22815
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Heroic work plunger man. Please allow me to introduce you to this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic