Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » How to Disable Package Matches Source Directory(When Java code directory does not match package name)
How to Disable Package Matches Source Directory [message #647189] Tue, 04 January 2011 22:04 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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.
Previous Topic:SWT for Eclipse 3.4.2 will not install
Next Topic:What is a LinkedHashSet ?
Goto Forum:
  


Current Time: Sun Feb 16 09:12:41 GMT 2025

Powered by FUDForum. Page generated in 0.04787 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top