Solved

Java - Jars, XML and Xerces

Posted on 2002-03-14
8
323 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
  • 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
 
LVL 9

Expert Comment

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

0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now