Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

NoClassDefFound Error in an Eclipse Export

 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey folks,

I'm looking at a project in Eclipse and, for the life of me, I can't figure out what I'm doing wrong.

The application I'm using utilizes an external API in order to connect to an FTP server, among other things. In Eclipse, I've pulled all of my needed JAR files into the build path and the application works perfectly. However, when I try to export the application as an executable JAR file, it's all falling apart.

I'm using Eclipse 2.1 (it's an old version, but I haven't used it in quite some time so I haven't upgraded it and lack the time to do so right now, anyway). From there, I select "Export..." and select JAR file.

The JAR File that it generates contains all of my CLASS files as well as a couple other files, named .classpath, .project, and Manifest.mf, respectively. Following are the contents of .classpath and Maifest.mf, as they may be relevant:



From the .classpath file, I would expect the application to find the file ftp.jar, which, indeed, is sitting on my C: drive. Unfortunately, it fails to do so. Whenever I execute the application, I eventually get this error:



I've tried everything I can think of, but it refuses to find that file. What can I do to make this work?

Thanks,
Corey

P.S.

Is there a way to deploy my JAR file with all of the JAR files it's dependent upon included within that JAR file? It would seem that, in such a way, deployment to other machines would be easier.
[ July 12, 2005: Message edited by: Corey McGlone ]
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm assuming you are running this with the -jar option.

You need to create your own Manfest.mf and include the Class-Path element as discribed Here

I'm not sure how in Eclipse you specify the manafest to include in the jar but, it should be that difficult.
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I'm assuming you are running this with the -jar option.



Yup, running it using java -jar NameOfJarFile.jar.

I've even tried using java -jar -classpath C:\ftp.jar NameOfJarFile.jar, but that didn't help, either.


You need to create your own Manfest.mf and include the Class-Path element as discribed Here

I'm not sure how in Eclipse you specify the manafest to include in the jar but, it should be that difficult.



Eclipse normally created the Manifest file for me, but I tried making my own, which included a Class-Path header. I used something like this:

Class-Path: ftp.jar

However, I'm guessing that assumes that the JAR file ftp.jar would be located within the .jar file of the application. While I know how to define the Manifest file, I don't know how to include those external .jar files within the application .jar.

If I remember correctly (I'm not currently at that workstation), I also tried something like this:

Class-Path: C:\ftp.jar

I think that one might have given me errors.
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
adding Class-Path: ftp.jar assumes the jar is in the same directory where you started the app.

If you use Windows \ you need to escape it.

Try using
Class-Path: c:/ftp.jar
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having the similar problem. While exporting my eclipse java project to a jar file, MF does not include the jars (plug-ins and externals) used in the buildpath of the project.

Please help me how to solve this problem using Eclipse.

Sabbir
 
sabbir kazi
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any solution for this problem? Please let me know.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just add in your .classpath

exported="true"

eg...
<classpathentry exported="true" kind="lib" path="C:/Documents and Settings/admin/.../kxml.jar"/>


It will working for me Try it ....
 
To get a wish, you need a genie. To get a genie, you need a lamp. To get a lamp, you need a tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic