How to Disable Package Matches Source Directory [message #647189] |
Tue, 04 January 2011 22:04  |
Eclipse User |
|
|
|
I import some old java codes into Eclipse. Eclipse reports error because the java code directory does not match the package definition.
For examples,
I have a java code at:
com\example1\featureA\FeatureATest.java
package peter.com.example1.featureA.FeatureATest;
for some reason, I can not change those old codes. Is any option in Eclipse that I can disable the package mismatch?
Thanks
|
|
|
Re: How to Disable Package Matches Source Directory [message #647214 is a reply to message #647189] |
Wed, 05 January 2011 06:03   |
Eclipse User |
|
|
|
On 1/5/2011 3:34 AM, Peter wrote:
> I import some old java codes into Eclipse. Eclipse reports error because
> the java code directory does not match the package definition.
they must match, it is a java requirement.
> For examples,
> I have a java code at: com\example1\featureA\FeatureATest.java
>
> package peter.com.example1.featureA.FeatureATest;
>
> for some reason, I can not change those old codes. Is any option in
> Eclipse that I can disable the package mismatch?
>
> Thanks
|
|
|
Re: How to Disable Package Matches Source Directory [message #711069 is a reply to message #647214] |
Fri, 05 August 2011 18:44  |
Eclipse User |
|
|
|
The answer from Deepak Azad is incorrect. There is no formal requirement in Java that they must match. The JLS merely says: "Packages that are stored in a file system may have certain constraints on the organization of their compilation units to allow a simple implementation to find classes easily."
Javac does not enforce this restriction, and neither do some other Java IDEs (e.g. JDeveloper, IntelliJ).
One may argue that it's a good idea for them match and one may be right. But that's different from making an absolute rule. I think this should be considered a bug in Eclipse.
|
|
|
Powered by
FUDForum. Page generated in 0.04787 seconds