Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Java - Jars, XML and Xerces

Posted on 2002-03-14
8
Medium Priority
?
339 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
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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:
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month14 days, 1 hour left to enroll

580 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