Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By Junky

Thread: Error when run from Command Prompt

  1. #1
    hqt
    hqt is offline Member
    Join Date
    Nov 2011
    Posts
    27
    Rep Power
    0

    Question Error when run from Command Prompt

    I have a simple "HelloWorld" program. (filename: HelloWorld.java)
    Java Code:
    class HelloWorld{
    public static void main(String[] args){
    System.out.println("Hello World");
    }
    }
    this program I run smoothly in NetBean IDE, but when I compiled it in command prompt, I have a problem:
    Java Code:
    javac HelloWorld.java  //Sucessful
    java HelloWorld.class //Error
    Error that I have received is:
    Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld/class
    Caused by:
    java.lang.ClassNotFoundException: HelloWorld.class
    at java.nt.URLClassLoader$1.run(Unknowwn Source)
    at java.securitiy.AccessController.doPriviledged (Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.LoadClass(Unknown Source)
    and some many line ... but still long that I cannot type :">

    So, It's really frustrate with me :( Who know this problem, please help me :(
    thanks :)

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default Re: Error when run from Command Prompt

    java FileName
    hqt likes this.

  3. #3
    ADustedEwok is offline Member
    Join Date
    Dec 2011
    Posts
    4
    Rep Power
    0

    Default Re: Error when run from Command Prompt

    1. You didnt path you program correctly to command prompt...

    2. You need to find the proper folder.
    cd documents
    then just do javac [whatever program is called].java
    finally java [whatever program is called]

    then should work... I just use bluej because it runs the program completely seperately in a console.

Similar Threads

  1. Letting my program command the command prompt
    By Smokey. in forum Threads and Synchronization
    Replies: 4
    Last Post: 03-30-2011, 12:34 AM
  2. New Command prompt
    By jmga9 in forum New To Java
    Replies: 4
    Last Post: 11-10-2010, 02:53 AM
  3. Error compiling java subclass from command prompt
    By littleone in forum New To Java
    Replies: 5
    Last Post: 10-26-2010, 04:45 PM
  4. error in the Command Prompt when running a bat file
    By bluesagemedia in forum New To Java
    Replies: 1
    Last Post: 10-03-2010, 02:05 AM
  5. How to return command prompt error message
    By raxwer in forum Advanced Java
    Replies: 3
    Last Post: 05-26-2010, 06:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •