views:

124

answers:

3

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?

+4  A: 

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

Michael Mrozek
Actually, this is a requirement of Eclipse, not Java.
SamBeran
Wow, you're right; I was positive Java required that. Fixed
Michael Mrozek
Where do I configure this in errors/warnings? I'm not seeing anything.
SamBeran
+6  A: 

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.

Jim Kiley
No, I can't change anything about the project at this time.
SamBeran
Then I'm afraid you're not going to be able to get the project to compile at all. Is there anything you can change?
Jim Kiley
I'm assuming that the project compiles, or it would need to be changed. There are all sorts of things that can be done in a build before `javac` is invoked, etc.
justkt
A: 

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.

aperkins