Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Java - Jars, XML and Xerces

Posted on 2002-03-14
8
Medium Priority
?
337 Views
Last Modified: 2013-11-23
Hello,

I'm trying to execute an application which calls xerces.jar.
Everything compiles and works as expected in my IDE (Visual Age Java).
I have exported my classes as jars.

When I try to execute the command:-

     java -jar -cp classpath myjar.jar classname

I receive the following error:-

Exception in thread "main" java.lang.NoClassDefFoundError: org/xml/sax/helpers/DefaultHandler
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)

I have checked that the xerces directory and jar file are in the classpath but can't get this to work.
I have tried replacing xerces.jar with another version of xerces...same problem.
As an FYI, am working on an HP-UX with Java 2 v1.3

Is this a simple classpath problem, an issue with my jar file or a xerces problem ?

Any help or pointers, greatly appreciated.

Andy
0
Comment
Question by:context
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 6867114
 I think it is a simple classpath problem.

  I do not know if this is going to help but try putting your Xerces.jar file under the /lib/ext folder. If this does not work try to unpack the Xerces.jar into your class path.

  Hope it helps.
0
 
LVL 9

Expert Comment

by:Venci75
ID: 6867507
try this:
java -jar -classpath myjar.jar;%CLASSPATH% classname

0
 

Author Comment

by:context
ID: 6867809
I also thought that this was a classpath problem.
However, I have tried playing with the classpath to no avail.

One thing to note, when I unpack my jars, it works.
Guess this is telling me that this isn't a problem with xerces.

I'm assuming that when using multiple jars, as long as the complete path of the jar (incl. jar name) is in the classpath, there shouldn't be any problems, right?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Expert Comment

by:Venci75
ID: 6867835
ops - sorry:
try this:
java -jar -cp $CLASSPATH myjar.jar classname

0
 
LVL 35

Expert Comment

by:girionis
ID: 6869951
>I'm assuming that when using multiple jars, as long as the complete path of the jar (incl. jar name)
>is in the classpath, there shouldn't be any problems, right?

  Yes this is right. But it's strange that it does not work while the classes are in the jar. The only thing I can think of is that there is a conflict with the class loaders. I am running out of ideas here. Try to use the . in your classpath, i.e. java -jar -classpath %CLASSPATH%;.

  And, did you try putting your jar file under the /lib/ext folder?
0
 
LVL 92

Accepted Solution

by:
objects earned 400 total points
ID: 6872554
When you use the -jar option the jar file is the source of all classes, and all other classpath settings are ignored.
ie. your classpath is not used.

You need to specify your external jars in your jar's manifest (use the Class-Path attribute) instead.
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6946494
ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101 or Netminder will return to finalize these if still open in seven days.  Please post closing recommendations before that time.

Question(s) below appears to have been abandoned. Your options are:
 
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> YOU CANNOT DELETE A QUESTION with comments; special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click this link for Help Desk, Guidelines/Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Click you Member Profile to view your question history and keep them updated as the collaboration effort continues, to maintain your open and locked questions.  If you are a  KnowledgePro user, use the Power Search option to find them.  Anytime you have questions which are LOCKED with a Proposed Answer which does not serve your needs, please reject it and add comments as to why.  In addition, when you do grade the question, if the grade is less than an A, please add a comment as to why.  This helps all involved, as well as future persons who may access this item for help.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.20194609.html
http://www.experts-exchange.com/questions/Q.20218717.html
http://www.experts-exchange.com/questions/Q.20119148.html
http://www.experts-exchange.com/questions/Q.20277152.html




**** PLEASE DO NOT AWARD THE POINTS TO ME. *****
 
------------>  EXPERTS:  Please leave your closing recommendations if this item remains inactive another seven (7) days.  If you are interested in the cleanup effort, please click this link http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643 
POINTS FOR EXPERTS awaiting comments are listed here -> http://www.experts-exchange.com/commspt/Q.20277028.html
 

Moderators will finalize this question if in @7 days you have not responded.  They will either move this to the PAQ (Previously Asked Questions) at zero points, delete it or awarding expert(s) when recommendations are made, or an independent determination can be made.  Expert input is always appreciated to determine the fair outcome.
 
Thank you everyone.
 
Moondancer
Moderator @ Experts Exchange
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 7116803
Zero response, finalized.
Moondancer - EE Moderator
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question