469,352 Members | 2,107 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

No Class Definition Found Error

2
I am completly new to Java and to programing in general. I have downloaded and installed JDK version 6, update 7 on my system runninig Windows XP SP3.
I have the path set and the compiler running but when I try the java command I get this error message;

Exception in thread "main" java.lang.NoClassDefFoundError: hello (wrong name: Hello)

I copied the sorce code exactly from the instructions I am following and have been searching the web for an answer.
Where did I go wrong?
Jul 11 '08 #1
7 10204
Dököll
2,364 Expert 2GB
Hey there partner!

Sorry for your troubles, I am sure it's annoying...

What type of compiler are you using? I am also knew to this, if you're using Eclipse for instance, you can right-click on he red x where yourerror shows and you'll have a variety of options you can use.

Hope you get this one nailed if it is so...

In a bit!
Jul 12 '08 #2
Laharl
849 Expert 512MB
Sounds like he's using the regular Sun command line tool. This is a classpath error. What you need to do is add '.', the current directory, to your Java classpath. How you do this I'm a little fuzzy, I'm afraid, as I use Linux, not Windows, for most of my dev work and use IDEs when in Windows for exactly this reason.
Jul 12 '08 #3
JosAH
11,448 Expert 8TB
Exception in thread "main" java.lang.NoClassDefFoundError: hello (wrong name: Hello)

Where did I go wrong?
The name of your class and/or file is wrong (see the error message). Java is
case sensitive and you have mixed up an upper or lowercase letter.

kind regards,

Jos
Jul 12 '08 #4
Hi,
Your problem is that of CLASSPATH Settings. It is an 'Environment Variable' (If you find the term strange, then just a VARIABLE. If you are working on Windows XP, then follow the simple steps below:
1. Right Click My Computer Icon in Desktop.
2.Switch to the ADVANCED TAB.
3.Add a Classpath variable to the system by clicking on new under USER VARIABLES.
4. A box will pop-up.
5. Enter CLASSPATH for VARIABLE NAME.
6. Enter '.;' (DOT-Semicolon) for VARIABLE VALUE.

The CLASSPATH simply specifies where your java.exe has to reside for successful execution of your program. You may ADD ANOTHER path by CONCATENATING it with the VARIBLE VALUE, separated by a semi-colon.

Think that should help you out of that.

AN ADVICE:

Running Java Programs can be a headache if you ignore Cases in Class-names etc. After this preoblem is solved, look out if you made any mistakes of that kind.
Jul 12 '08 #5
JosAH
11,448 Expert 8TB
The CLASSPATH simply specifies where your java.exe has to reside for successful execution of your program.
That is just nonsense. And the OP's problem isn't a classpath issue either: the
JVM did find a file but the name didn't correspond with the class stored in that
file. Probably an uppercase/lowercase problem. Setting the environment variable
CLASSPATH is a clumsy way to set your classpath; read this for a nice
explanation of what the classpath actually is. It is not for locating your java.exe;
you'll need the PATH variable for that.

kind regards,

Jos
Jul 12 '08 #6
3rds
2
It was an uppercase/lowercase problem. Thanks for the help and advice. Now I can start moving forward again and maybe be a little more pleasent to be around.
Thank You All
Jul 13 '08 #7
JosAH
11,448 Expert 8TB
It was an uppercase/lowercase problem. Thanks for the help and advice. Now I can start moving forward again and maybe be a little more pleasent to be around.
Thank You All
Good to hear; lesson learned: always carefully read the error diagnostic message;
all the information is in there (see your original post and error description). btw,
you weren't unpleasant at all. Incorrect advice is more of a nuisance than questions
like yours.

kind regards,

Jos
Jul 13 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Tony Johansson | last post: by
3 posts views Thread by Tony Johansson | last post: by
5 posts views Thread by BlackBeltNerd | last post: by
2 posts views Thread by Marcosu | last post: by
10 posts views Thread by SpreadTooThin | last post: by
3 posts views Thread by =?Utf-8?B?TWFyaw==?= | last post: by
1 post views Thread by vijayann | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.