Eclipse to Java command line

Discussion in 'Java' started by Srini -, Apr 29, 2010.

  1. Srini -

    Srini - Guest

    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
     
    Srini -, Apr 29, 2010
    #1
    1. Advertising

  2. Srini -

    Lew Guest

    Srini - wrote:
    > 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.

    --
    Lew
     
    Lew, Apr 29, 2010
    #2
    1. Advertising

  3. Srini -

    EmeCas Guest

    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

    On Apr 29, 1:03 pm, Srini - <> wrote:
    > 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
     
    EmeCas, Apr 29, 2010
    #3
  4. Srini -

    Srini - Guest

    On Apr 29, 7:25 am, Lew <> wrote:
    > Srini - wrote:
    > > 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.
    >
    > --
    > Lew


    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
     
    Srini -, Apr 29, 2010
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dale
    Replies:
    1
    Views:
    563
    iksrazal
    Jul 8, 2004
  2. jayshao
    Replies:
    1
    Views:
    3,248
  3. Eitan M

    command line from eclipse

    Eitan M, Aug 12, 2007, in forum: Java
    Replies:
    0
    Views:
    377
    Eitan M
    Aug 12, 2007
  4. Tack
    Replies:
    11
    Views:
    2,075
    Andrew Thompson
    Jun 29, 2008
  5. Giuseppe:G:
    Replies:
    0
    Views:
    323
    Giuseppe:G:
    Jul 4, 2008
Loading...

Share This Page