Allow Incorrect Package Name in Eclipse
I have some classes in my current开发者_如何转开发 project which have the wrong package declaration (they are in the wrong folder for their declared package.)
Unfortunately, fixing the problem by moving the class is not an option. Is there a way I can get eclipse to ignore the error?
You can fiddle with Eclipse's display in the "Errors/Warnings" section of preferences, but Java requires that you have files in the correct folder to match their package, so it won't be able to build
If fixing the problem by moving the class is not an option, is fixing the problem by changing the declared package name an option? If you can't do one of those two things, the code won't compile -- so this wouldn't be an Eclipse problem so much as a Java problem.
Do you have the source folder for Eclipse at the right level? The source folder for Eclipse should be at the level where the package folders start. If there are multiple folders with separate package structures, each one would be it's own source folder.
精彩评论