When I was doing a Java primer, the first Java program written in the tutorial was:
public class HelloWorld {/* first Java program * It will print a string Hello world * /public static void main (string []args) {
system.out.println ("Hello World"); Print Hello World }}
The suffix of this file is. java, then use cmd (Command prompt tool) to type in the current directory: Javac Helloworld.java, and then press the ENTER key to generate a class file with the suffix. Class in the current directory. Then when I type in cmd: Java HelloWorld, and press ENTER to run after the result error: "Cannot find or Load main class".
This problem occurs because the configuration of the environment variable classpath was not configured at the time of the problem, my previous classpath configuration is the JDK installation directory of the Lib folder, namely: "D:\working\Java\jdk-9.0.4\lib". But this is not enough, but also need to precede a period and a semicolon, that is: ".;D: \ Working\java\jdk-9.0.4\lib ". Then close the previous cmd, reopen it into the current directory, then type: Java HelloWorld, press ENTER to run the program, everything is OK.
Good luck!
java HelloWorld times error: "The main class cannot be found or cannot be loaded" solution to the problem