Solved

Java - Jars, XML and Xerces

Posted on 2002-03-14
8
330 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
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 
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 100 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

691 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