Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Problems in setting classpath

  1. #1
    Junior Member
    Join Date
    Jun 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problems in setting classpath

    Hello,

    I am a newbie here. I have a problem and have no idea how to solve it. I am trying to run a code for extracting text from PDF document. In order to compile and run the code, I need to add PDFBox-0.7.3.jar to the classpath. I really hope anyone can help me how to solve this problem. Thanks in advance.

    The compilation is successfully done using command as below:

    >javac -classpath PDFBox-0.7.3.jar PDFTextParser.java

    Then, unfortunately, when I tried to run the code, it ended up to give me these errors. The command used as below:

    >java -classpath PDFBox-0.7.3.jar PDFTextParser testing.pdf testOut.txt

    Errors displayed
    Exception in thread "main" java.lang.NoClassDefFoundError: PDFTextParser
    Caused by: java.lang.ClassNotFoundException: PDFTextParser
    at java.net.URLClassLoader$1.run(Unknown Source)
    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)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    Could not find the main class: PDFTextParser. Program will exit.

    I have tried another way by using the command as below without setting the classpath and the different type of errors appear.

    >java PDFTextParser testing.pdf testOut.txt

    Errors Displayed

    Parsing text from PDF file testing.pdf....
    Exception in thread "main" java.lang.NoClassDefFoundError: org/pdfbox/pdfparser/PDFParser
    at PDFTextParser.pdftoText(PDFTextParser.java:50)
    at PDFTextParser.main(PDFTextParser.java:107)
    Caused by: java.lang.ClassNotFoundException: org.pdfbox.pdfparser.PDFParser
    at java.net.URLClassLoader$1.run(Unknown Source)
    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)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    ... 2 more
    Last edited by missyati; June 29th, 2009 at 02:43 AM.


  2. #2
    Member Truffy's Avatar
    Join Date
    May 2009
    Location
    Philippines
    Posts
    93
    Thanks
    2
    Thanked 9 Times in 7 Posts

    Default Re: Problems in setting classpath

    Quote Originally Posted by missyati View Post
    Hello,

    I am a newbie here. I have a problem and have no idea how to solve it. I am trying to run a code for extracting text from PDF document. In order to compile and run the code, I need to add PDFBox-0.7.3.jar to the classpath. I really hope anyone can help me how to solve this problem. Thanks in advance.

    The compilation is successfully done using command as below:

    >javac -classpath PDFBox-0.7.3.jar PDFTextParser.java

    Then, unfortunately, when I tried to run the code, it ended up to give me these errors. The command used as below:

    >java -classpath PDFBox-0.7.3.jar PDFTextParser testing.pdf testOut.txt

    Errors displayed
    Exception in thread "main" java.lang.NoClassDefFoundError: PDFTextParser
    Caused by: java.lang.ClassNotFoundException: PDFTextParser
    at java.net.URLClassLoader$1.run(Unknown Source)
    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)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    Could not find the main class: PDFTextParser. Program will exit.

    I have tried another way by using the command as below without setting the classpath and the different type of errors appear.

    >java PDFTextParser testing.pdf testOut.txt

    Errors Displayed

    Parsing text from PDF file testing.pdf....
    Exception in thread "main" java.lang.NoClassDefFoundError: org/pdfbox/pdfparser/PDFParser
    at PDFTextParser.pdftoText(PDFTextParser.java:50)
    at PDFTextParser.main(PDFTextParser.java:107)
    Caused by: java.lang.ClassNotFoundException: org.pdfbox.pdfparser.PDFParser
    at java.net.URLClassLoader$1.run(Unknown Source)
    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)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    ... 2 more
    hi missyati,

    welcome to the java programming forums.

    here's some site about setting the classpath:

    How to set the Java classpath
    Java How To ...: 6 Ways of Setting Java Classpath


    hope it can help you.

  3. #3
    Junior Member
    Join Date
    Jun 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Problems in setting classpath

    Thank you so much for the information. Actually, I have solved the problem. On the run command I've missed to put ; after .jar. Simple mistake

  4. #4
    Member Truffy's Avatar
    Join Date
    May 2009
    Location
    Philippines
    Posts
    93
    Thanks
    2
    Thanked 9 Times in 7 Posts

    Default Re: Problems in setting classpath

    Quote Originally Posted by missyati View Post
    Thank you so much for the information. Actually, I have solved the problem. On the run command I've missed to put ; after .jar. Simple mistake
    okay. Please mark as solved.

    Cheers,
    Truffy

Similar Threads

  1. Replies: 1
    Last Post: April 1st, 2009, 02:47 PM