Java tutorial-CMD manual compilation and running failure cause (Master skipped), java failure cause
(This is only for beginners and masters) when we use cmd to manually compile a Java program at the early stage of learning java, we will encounter a successful compilation, but the running will always prompt a failure. The java configuration environment has been ruled out. The Path settings for Path, ClassPath, and % JAVA_HOME are all correct, and the file name for compiling and running is case-insensitive. So why? See the following brief analysis. For example
The source code is as follows:
1 package lee; 2 public class Hello3 {4 public static void main (String [] args) 5 {6 System. out. println ("HelloWorld !"); 7} 8}
We do not have a package concept for new users, but we will be confused at the beginning of the program.Package lee;
The cause of this error is here. Our Hello class is stored under the package lee, so the compiled Hello. the class should be stored in the lee folder, but during practice, we usually compile and save it in the same directory, as a result, the system prompts "cannot be found or the main class Hello cannot be loaded" during running ".
Solution:
Method 1: DeletePackage lee;This line.
Method 2: place the generated Hello. class file in the lee folder.
After the change, the system runs normally.