JAR problem

A

Ajay Singh Tomar

Hello All,

I have created a Jar file for my project with *.classes, lib folder and
Manifest file.

I can run the Jar file successfully to get desired output from the same
directory, I have created the Jar file from.

But when I copy the Jar file to different folder or different PC, the
program runs but crashes at JDOM exception

Exception in thread "main" java.lang.NoClassDefFoundError:
org/jdom/JDOMException at XMLMerger.main(XMLMerger.java:47)

Could anyone tell me what could be the problem?

Here is the MANIFEST.MF file contents.

----------------------------------------------------------------------------
-----
Manifest-Version: 1.0
Main-Class: XMLMerger
Class-Path: lib/jaxen-full.jar lib/jdom.jar lib/saxpath.jar
lib/xercesImpl.jar lib/xmlParserAPIs.jar
----------------------------------------------------------------------------
-----



Thanks in anticipation.

Regards,
Ajay
 
A

Ajay Singh Tomar

Here is the MANIFEST.MF file contents.

Manifest-Version: 1.0
Main-Class: XMLMerger
Class-Path: lib/jaxen-full.jar lib/jdom.jar lib/saxpath.jar
lib/xercesImpl.jar lib/xmlParserAPIs.jar

Regards,
Ajay
 
C

Chris Smith

Ajay said:
I have created a Jar file for my project with *.classes, lib folder and
Manifest file.

I can run the Jar file successfully to get desired output from the same
directory, I have created the Jar file from.

But when I copy the Jar file to different folder or different PC, the
program runs but crashes at JDOM exception

Exception in thread "main" java.lang.NoClassDefFoundError:
org/jdom/JDOMException at XMLMerger.main(XMLMerger.java:47)

Could anyone tell me what could be the problem?

Sure. Your manifest file looks like this:
Manifest-Version: 1.0
Main-Class: XMLMerger
Class-Path: lib/jaxen-full.jar lib/jdom.jar lib/saxpath.jar
lib/xercesImpl.jar lib/xmlParserAPIs.jar

which means that the JRE will look for a subfolder called 'lib' of
whatever folder contains your JAR file. Instead, though, it sounds from
the above as if you've actually placed your JAR files inside the
executable JAR. That doesn't work. You need a directory structure that
looks like this:

/somepath/my.jar
/somepath/lib/jaxen-full.jar
/somepath/lib/jdom.jar
/somepath/lib/saxpath.jar
/somepath/lib/xercesImpl.jar
/somepath/lib/xmlParserAPIs.jar

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
D

Daniel Schneller

Hi!
I have created a Jar file for my project with *.classes, lib folder and
Manifest file.
Sounds good so far, except for the lib folder...
I can run the Jar file successfully to get desired output from the same
directory, I have created the Jar file from.
That is quite normal. Your application can read the jars from the lib
folder, i. e. *not* from the newly built jar file. You cannot nest jars
in jars. You have two alternatives:

- unpack all jars and repack them into a single one without an included
"lib" folder
- copy your lib folder *and* your own jar to the 2nd machine. You could
zip them together and make them self extracting.

Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top