Symptom: It can be compiled by using eclipse and other IDE development tools, but can be run. However, it can be compiled by saving dos in notepad and cannot be run. The error "exception in thread" Main "Java. lang. noclassdeffounderror ".
Solution: 1. It is impossible to set environment variables incorrectly because integrated development tools can run
2. I wrote a simple "helloworld" again in notepad"Program, Compilation can be passed and run perfectly. Once again, it is determined that it is not a problem with environment variable configuration.
3. Later, we removed the package in the program and re-compiled it to run it. This should be caused by the package name.
If the class contains a package name, run it in the command line.
1.
javac test. java // compile the test class to produce the class file
JAVA test // run the test class
2. com. application. test
javac-D. test. java // The class file that can generate the package, that is, the folder generated in the development tool
java com. application. test // run this class
start to run the Java package name at the beginning of your package name. class Name. For example, if your class file is stored in your project directory, assume that your class file is com. XX. my. class. In this way, the project directory must have a package structure such as COM/XX/My, because your classpath has. this path should now run the Java package name in the project directory. class Name command if you directly go to the projrdbms/COM/XX/My directory, the above error will appear, Because you tell the virtual machine to find the class from the current path, and the current text The folder does not contain the COM/XX/My directory !!