Help--Exception in thread "main" java.lang.NoClassDefFoundError: Example

Hi, I am really new with this JAVA.After i Downloaded the JDK6 updates 2. I start to installed and set the path on the C:\Program Files\Java\jdk1.6.0_02\bin

I have made the source code from notepad named it as Example.java and put it in the folder C:\Javacode. I have compile the code using javac command but then i found the error message of :

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

after i try to run the program...

Thanks before

[490 byte] By [franc86a] at [2007-11-27 11:41:21]
# 1

Give us the exact commands you're using to compile and run.... just copy and paste the whole cmd window between a couple of [pre] ... [/pre] tags.

corlettka at 2007-7-29 17:37:41 > top of Java-index,Java Essentials,New To Java...
# 2

C:\>cd javacode

C:\>JavaCode>javac Example.java

C:\>JavaCode>java Example

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

franc86a at 2007-7-29 17:37:41 > top of Java-index,Java Essentials,New To Java...
# 3

set classpath to C:\>JavaCode either in command line

set CLASSPATH=C:\javacode;%CLASSPATH%

or set Environment variable "CLASSPATH"

prassoona at 2007-7-29 17:37:41 > top of Java-index,Java Essentials,New To Java...
# 4

I wouldn't recommend setting the CLASSPATH variable... it's OK for now, but it'll become problematic in the long term... so IMHO you may as well form good habits upfront.

To compile:

C:\javacode>javac -d "." Example.java

To execute:

C:\javacode>java -classpath "." Example

Or as of java 1.5 you can shorten that to:

C:\javacode>java -cp "." Example

java -version

tells you which version of java you're running.

Cheers, Keith.

corlettka at 2007-7-29 17:37:41 > top of Java-index,Java Essentials,New To Java...