Exception in thread "main" java. Lang. noclassdeffounderror error message

Source: Internet
Author: User

1. Is your file name correct?
Java requires that your file exactly match your class name.
For example, public class helloworld {.....
The file name must be helloworld. java. Check it carefully!

2. Do you have the main method in your program? Are the parameters correct?
The Declaration of the main method should be like this:
Public static void main (string [] ARGs)
In fact, if you use development tools, it will not be wrong. If you use ultraedit or another type to write a program, do not copy a word!

3,Remember, the parameters behind javac are file names, but those behind Java are class names!
This is what I made when I started learning java. Java helloworld. class, and then I will report an error. Later I realized that it should be Java helloworld.

I am making this mistake. I first read that the environment variable configuration and other settings are correct, that is, this error is reported. In the end, I found that the class name is followed by the original Java, instead of file name

4. Have you set classpath?
It is not only the content to be set during JDK installation, but also a directory to store your class files. For example, D:/class directory.
Set classpath = % classpath %; D:/class
Now, copy the helloworld. Class file to the D:/class directory, and then Java helloworld should be OK.

5. Combine points 3rd and 4th
If your class belongs to a certain package, such as Sony. test. helloworld, so according to the directory I mentioned in the 4th point, we should put helloworld. the class file is stored in the D:/class/Sony/test/directory.
During execution, you should refer to the section 3rd "execute by Class Name: Java Sony. Test. helloworld.

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.