The declared package does don't match the expected package

Source: Internet
Author: User

Original link: http://www.cnblogs.com/davidwang456/p/3554350.html

The console is prone to a large number of errors when eclipse imports the source code into the project using import or through SVN checkout and other ways to import the source into the project.

However, compiling directly with the ant script will compile successfully.

This time please don't worry, open errors can be seen at the beginning of many classes: Package error, prompt:

The declared package does don't match the expected package

The cause of the error is:

The definition of a package in eclipse is typically generated through the package name, rather than through the hierarchy of the file. Eclipse imports the source code using import, the import is the file structure rather than the package form, so error.

Workaround:

Click > Properties > Java Build path > Source > Add Folder > selectsrc/XXXX

And then recompile is OK.

The declared package does don't match the expected package

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.