Can't execute java files on command prompts when they work perfectly in Eclipse IDE, what to do?

Posted by Eduardo de Luna on Super User See other posts from Super User or by Eduardo de Luna
Published on 2012-10-21T20:32:54Z Indexed on 2012/10/21 23:06 UTC
Read the original article Hit count: 180

Filed under:
|

I run the following code in Eclipse IDE:

public class HelloWorld {
    public static void main(String[] args)
    { 
    System.out.println("Hello World!" ) ; 
    }
}

And it renders the expected output.

When getting into the command prompt (DOS) already in the directory, I type this

javac HelloWorld.java

And then this

java HelloWorld

And the output reads

Exception in thread "main" java.lang.NoClassDefFoundError: 
HelloWorld <wrong name:learning/HelloWorld>

With a whole lot more errors, learning being the name of my general package. What's wrong? I have installed Eclipse x86 SDK 4.2.0 together bit with the latest JRE and JDK both in 64 bit as well.

© Super User or respective owner

Related posts about command-line

Related posts about java