Recently read Java, but a seemingly very basic hellorworld headache for more than 10 minutes, Baidu a bit, if you edit and run under CMD. java file times wrong, the solution is as follows:
D. Java files under the packing directory.
Open cmd and enter the D packing directory for Javac Demo.java,:
This step is not error, because as long as your classpath setup success, there will be no error problem,
At this point we see that the Demo.class just compiled has already appeared in the root directory.
When we proceed to the next step, we will find a cmd error:
Believe that a lot of students have just started to meet this problem, Baidu check up time and effort, and sometimes many people write the solution will not solve the problem at all.
Then we go directly to the dry goods, this kind of problem arises, is often caused by incomplete configuration of classpath.
:
in the classpath of the environment variable, the value of the variable is prepended. When you are sure, rerun cmd to resolve the problem :
As for how to configure the environment variables, please see my previous Java perfect configuration strategy.
The workaround for the main class cannot be found or cannot be loaded when running a Java file under cmd