Cmd command line compiling and running java program error NoClassDefFoundError, command line compiling java
First, when the java program runs this error, first consider whether it is a path or the correct package name is not specified. For example, when running the following file:
1 package cn. wgh. socket; 2 3 public class HelloWorld {4 5 public static void main (String [] args) {6 System. out. println ("Hello world! "); 7 8} 9 10}
You should set the cmd directory to the root directory of the project before running the operation. For example, my project directory is like this:
E: \ Work \ MyJava \ SocketDemo \ src \ cn \ wgh \ socket \ HelloWorld. java
The command should be:
E: \ Work \ MyJava \ SocketDemo \ src> java cn. wgh. socket. HelloWorld
Second, compile the file directly in the directory where the file is located.
The entire process is as follows:
My original address:
Http://www.timegowhere.com/post/noclassdeffounderror.html