Noclassdeffounderror occurs during Java execution.

Source: Internet
Author: User

 

The main cause of this error is the package name in the program. The program is as follows:

Package imputationrareprob; public class imputationrareprob {public static void main (string [] ARGs) {system. Out. println (ARGs [0]);}

Note the package at the top layer of the program. If you run the package as follows, this error will occur.

If you run it in the following way, the noclassrareprob error will occur, but if you use eclipse to run it, there will be no error. The reason is that eclipse has done a lot for us.

Javac imputationrareprob. Java

// There is no error at this point. It succeeds and then tries to run the generated. Class file, noclassdeffounderror will appear.

Java imputationrareprob

// An error will be reported here.

This is because "the package exists"

The significance of the package is to generate a directory structure, so the class file must be in the corresponding directory hierarchy, so the correct approach should be like this

Javac-D. imputationrareprob. Java

The-D option specifies the directory for generating the class file. The following screenshot shows the directory structure of the generated class file.


The second is the content in the above folder, and the execution should also be in the directory where imputationrareprob. Java is located.

Java imputationrareprob/imputationrareprob
Otherwise, the same error will occur. Therefore, you must be especially careful when compiling Java programs involving packages.

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.