Martin's Tex-Blog

Posts on programming and generally technical topics

Classes from unnamed (default) package is not visible from class in named package

leave a comment »

Well, this is a well known fact for around 10 years now, but I got trapped into compilation error involving this “feature” recently. Here is more detailed explanation:

to make this story short – always remember to put your classes into packages, and never try to use class from unnamed package from within named package class, compiler will not give you meaningful error notice.

This is only valid for compilers from 1.4 and up. If you have some older class files which were in unnamed package then they are no longer usable – unless you have sources.  Well – actually there is a method, use reflection API.


Written by Marcin

April 10, 2010 at 10:16 pm

Posted in Java, SCJP

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: