Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


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.

share|improve this question
up vote 2 down vote accepted

Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld

My guess is, you ran java HelloWorld from within the learning directory, right? But the command is expecting the class without any package. Since it's saying wrong name:learning/HelloWorld, it means it expects to find the HelloWorld class inside the learning package/directory, not in the current one.

Go one directory up in the hierarchy (cd..), then try running the program with
java learning.HelloWorld instead.

share|improve this answer
Thank you very much Karan and Darth Android! – Eduardo de Luna Oct 22 '12 at 1:41
@Darth: cd is an internal command. I have been using cd.. since the DOS days, it works. – Karan Oct 22 '12 at 11:13
@Karan cd.. is an alias intended to help people who typo cd .. - cd.. does not work on *nix or OSX systems (unless you go out of your way to add such an alias manually), while cd .. is more or less universal-- It works on Linux, OS X, Solaris, Windows' cmd.exe, and Windows' Powershell. I would argue it's bad form to suggest people use cd.. over cd .. – Darth Android Oct 22 '12 at 14:13
@Darth: I agree about cd.. working OOTB only in DOS/Win, which is what the OP has. Don't want to argue, but I guess when moving from Windows to a Linux shell this is hardly gonna be the biggest adjustment he'll need to make. Anyway, I don't know one single person who types cd .. or `cd \` in DOS/Win. – Karan Oct 22 '12 at 21:43
Coming back to your first sentence though (since I'm interested in such historical titbits), do you have any source to show that Tim Paterson (or whoever added this feature) did it simply to help with typos, or was this specifically developed as a feature for the DOS command interpreter/parser to prevent excessive typing (all those spaces add up after all)? – Karan Oct 22 '12 at 21:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .