Eclipse to Java command line

S

Srini -

All

I developed a test program using xerces to parse xml. Under eclipse I
am able to run it. Now I am trying to run from a command line and I
cannot get java to open the xercesImpl.jar.

My dir structure:

top - xercesImpl.jar
+-----bin pdfHello.class

java -verbose -cp xercesImpl.jar -classpath .\:bin\ pdfHello %1

is the command I am using.

I have tried many combinations of specifying the classpath but java
always complains:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/
xerces/parsers/SAXParser
at pdfHello.parseConfig(pdfHello.java:22)
at pdfHello.main(pdfHello.java:47)
Caused by: java.lang.ClassNotFoundException:
org.apache.xerces.parsers.SAXParser
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:
301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 2 more

Any clues deeply appreciated.

Cheers, srini
 
L

Lew

Srini said:
All

I developed a test program using xerces to parse xml. Under eclipse I
am able to run it. Now I am trying to run from a command line and I
cannot get java to open the xercesImpl.jar.

My dir structure:

top - xercesImpl.jar
+-----bin pdfHello.class

java -verbose -cp xercesImpl.jar -classpath .\:bin\ pdfHello %1

is the command I am using.

Not sure why you're including the Xerces JAR in your classpath at all, but
regardless, your command line is totally out of line with the documented options:
<http://java.sun.com/javase/6/docs/technotes/tools/windows/java.html>

You shouldn't specify the "classpath" option twice, and Windows doesn't
separate classpath entries with the colon character, but the semicolon.

<http://java.sun.com/javase/6/docs/technotes/tools/windows/classpath.html>

Tell us what happens when you fix those two things.
 
E

EmeCas

Hello

If your class is not in a package and xercesImpl.jar is in the
previous folder, i think the correct line from command line in the bin
folder is :

windows:

java -verbose -cp .;../xercesImpl.jar pdfHello argument

linux:

java -verbose -cp .:../xercesImpl.jar pdfHello argument

EmeCas
 
S

Srini -

Not sure why you're including the Xerces JAR in your classpath at all, but
regardless, your command line is totally out of line with the documented options:
<http://java.sun.com/javase/6/docs/technotes/tools/windows/java.html>

You shouldn't specify the "classpath" option twice, and Windows doesn't
separate classpath entries with the colon character, but the semicolon.

<http://java.sun.com/javase/6/docs/technotes/tools/windows/classpath.html>

Tell us what happens when you fix those two things.

many many thanks. i was misled by some clues.

I changed my command as follows:

java -cp xercesImpl.jar;bin pdfHello %1

and now it is working. I think I am beginning to get a hang of it.

Thanks once again, srini
 

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

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top