I installed Java 1.7.0 in the following folder C:\\Program Files\\Java
. My operating system is Windows XP(Version 2002) with Service pack 3.
The envir
You either want to add "." to your CLASSPATH to specify the current directory, or add it manually at run time the way unbeli suggested.
I have also faced same problem....
Actually this problem is raised due to the fact that your program .class
files are not saved in that directory. Remove your CLASSPATH from your environment variable (you do no need to set classpath for simple Java programs) and reopen cmd prompt, then compile and execute.
If you observe carefully your .class
file will save in the same location. (I am not an expert, I am also basic programer if there is any mistake in my sentences please ignore it :-))
Tell it where to look for you class: it's in ".", which is the current directory:
java -classpath . HelloWorld
No need to set JAVA_HOME
or CLASSPATH
in this case
I had the same problem. Perhaps, the problem is that you have compiled and executed the class with different Java versions.
Make sure the version of the compiler is the same as the command "java":
javac -version
java -version
In Linux, use
sudo update-alternatives --config java
to change the version of Java.