Can't seem to get my head around what is causing this error. I have set the CLASSPATH in Environment Variables to C:\Program Files\Java\jdk-10.0.2\bin
.
I can compile the code into a .class
file using javac HelloWorld.java
. However when trying to run the .class
file using java HelloWorld
, I am getting the below error:
I am running the code from C:\Java
which is the directory of both my .java
and .class
file.
c:\Java>java HelloWorld
Error: Could not find or load main class HelloWorld
Caused by: java.lang.ClassNotFoundException: HelloWorld
CODE:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
Any tips would be greatly appreciated.