Answer: Why is exception in ThreadMain java.lang.NoClassDefFoundError wrong when executing a Java program? ...

Source: Internet
Author: User
Tags copy execution
error| Program | Execution should do this by checking your environment and your actions:

1, your name is right?
Java requires that your file be strictly corresponding to your class name.
For example, public class helloworld{...
Then the filename must be Helloworld.java, look carefully!

2. Do you have a main method in your program? Parameters or something, right?
The declaration of the main method should be like this:
public static void Main (string[] args)
In fact, you can't be wrong if you use development tools to do it. If you use UltraEdit and so on to write the program, just a word do not change the copy it!

3, remember, javac behind the parameter is the filename, but Java followed by the class name!
This is my first learning Java is a mistake, Java Helloworld.class, and then the error. Later to understand, it should be Java HelloWorld.

4, set up the classpath?
Not only is the content to be set when installing the JDK, it is generally best to set up a directory to store your own class files. such as the D:\class directory.
Set classpath=%classpath%;d: \class
So, now copy the Helloworld.class file to the D:\class directory, and then the Java HelloWorld should be OK.

5. Combining 3rd and 4th
If your class belongs to a particular package, such as a class Sony.test.HelloWorld, then the Helloworld.class file should be stored in the d:\class\sony\test\ directory, as I mentioned in the 4th.
The execution should refer to the 3rd, according to the class name: Java sony.test.HelloWorld.

Do you understand? I can not think of any reason to cause this error message! If any brother thought of it, add it!
In fact, if you use some of the better programming tools, there is no chance to encounter this error, at least I am using the visualage for Java, there is no such thing.

Well, no, I wish the comrades good luck!
After this first door, the back is relatively simple!

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.