Help! I can compile my MyFirstApp.Java file, but I cannot run the MyFirstApp.Class File. I've tried several suggestions posted at various websites that say it is my CLASSPATH environment variable and suggest changes, but nothing works. Below I have included my code and the latest settings I am working with. I am running Windows XP, and I wonder if this is part of the problem?
I am so frustrated! I would greatly appreciate some help!
Thank you,
Simon
This is my file MyFirstApp.Java:
------------------------------------------------------------
class MyFirstApp{
void main(){
System.out.print("Hello World");
}
}
-------------------------------------------------------------
My PATH variable is the following: "C:\Program Files\Java\jdk1.5.0_04\bin"
My CLASSPATH variable is the following: "."
Please note that my PATH variable is a system variable, and I can query it through the Command Prompt. My CLASSPATH variable is User Variable. I can see it in the Control Panel->System->Advanced->Environment Variables...but when I query it through the Command Prompt I get an error.
-------------------------------------------------------------
When I type "javac MyFirstApp.java" at the command prompt, the file compiles fine and the MyFirstApp.class file is created (in the same directory)
-------------------------------------------------------------
When I type "java MyFirstApp.class" I get the following error:
"Exception in
thread "main" java.lang.NoClassDefFoundError: myfirstapp/class"
--------------------------------------------------------------
When I type "java -version" I get the following:
"java version "1.5.0_04"
java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) Client UM (build 1.5.0_04-b05, mixed mode, sharing)"
-----------------------------------------------------------------