File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes IDEs, Version Control and other tools and the fly likes NoClassDefFound Error in an Eclipse Export Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "NoClassDefFound Error in an Eclipse Export" Watch "NoClassDefFound Error in an Eclipse Export" New topic
Author

NoClassDefFound Error in an Eclipse Export

Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
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 ]

SCJP Tipline, etc.
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
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.


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
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

Joined: Jun 13, 2000
Posts: 3340
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
sabbir kazi
Ranch Hand

Joined: Feb 03, 2001
Posts: 62
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

Joined: Feb 03, 2001
Posts: 62
Any solution for this problem? Please let me know.
rajesh parmar
Greenhorn

Joined: Jan 18, 2010
Posts: 1
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 ....
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: NoClassDefFound Error in an Eclipse Export