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 3 of 3

Thread: ClassNotFoundException When running through commad line

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

    Default ClassNotFoundException When running through commad line

    Hi,

    I have writen a script using the json array library. I have imported the library into my project in eclipse and the programe runs fine through the eclipseterminal but when running it through Command Prompt it calls a ClassNotFoundException.

    I assume this is, for some reason, becuase the json library didnt compile. But im not to sure.

    This is the error that is displayed when trying to run the programe.

    C:\Users\user\Documents\workspace\Primes\bin>java PrimesMain
    Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONException
    Caused by: java.lang.ClassNotFoundException: org.json.JSONException
    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: PrimesMain. Program will exit.

    Please can some one help?


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: ClassNotFoundException When running through commad line

    You need to specify the classpath on where the JVM can find any additional libraries.

    See Setting the class path

    // Json

  3. The Following User Says Thank You to Json For This Useful Post:

    tomiroth (November 26th, 2009)

  4. #3
    Junior Member
    Join Date
    Nov 2009
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: ClassNotFoundException When running through commad line

    Thank you this has worked

Similar Threads

  1. ClassNotFoundException (bit weird)
    By chronoz13 in forum Exceptions
    Replies: 1
    Last Post: April 26th, 2011, 02:15 AM
  2. [SOLVED] ClassNotFoundException - Please Help
    By igniteflow in forum Exceptions
    Replies: 11
    Last Post: October 3rd, 2010, 10:50 PM
  3. ClassNotFoundException ???
    By wolfgar in forum JDBC & Databases
    Replies: 2
    Last Post: November 20th, 2009, 01:35 PM
  4. Reading a file line by line using the Scanner class
    By JavaPF in forum File Input/Output Tutorials
    Replies: 0
    Last Post: April 17th, 2009, 07:34 AM
  5. How to Read a file line by line using BufferedReader?
    By JavaPF in forum File Input/Output Tutorials
    Replies: 0
    Last Post: May 19th, 2008, 06:32 AM

Tags for this Thread