Explanation of "exception in thread" main "java. Lang. noclassdeffounderror"

Source: Internet
Author: User

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 !!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.