Community
Participate
Working Groups
Apparently the java compiler does not allow the explicit import of classes in the default package. Instead the compiler automatically finds the classes in the default package without the import statement. Eclipse has a problem here. I have two Classes: X.java: public class X { } a/Y.java: package a; public class Y { X mX; } I get the following error message: X cannot be resolved to a type Y.java test/a line 2 If I try to import X explicitly as follows I get another error: a/Y.java: package a; import X; public class Y { X mX; } The import X cannot be resolved Y.java test/a line 2 I know the use of the default package is discouraged, but some legacy code still hangs around.
From 1.4 on, the language spec has evolved to explicitly disallow importing from the default package. If you want to still use this feature, you have to manually set the compliance level back to 1.3 (see under Java compiler preferences).
*** Bug 81782 has been marked as a duplicate of this bug. ***
In 3.1RC3, setting the Compiler compilance level to 1.3 with the default compliance settings, this is still a problem. I ran into this while trying to verify bug 8722.
Created attachment 23883 [details] archive of broken project
3.1 RC3 works perfectly fine. In compliance 1.3, you can import from the default package. In your test case, I don't see an import for the Util class. This means the compiler tries to find Util in the current package, i.e. com.nitin. You need to add: import Util; And then it will work fine. Closing as INVALID.