Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2006

Tip: Looking for answers? Try searching our database.

Use of the default package in Eclipse

Thread view: 
Josh Zenker - 02 Sep 2006 00:55 GMT
I'm relatively new to Java and have been using Eclipse as my IDE.
Would someone please explain why it discourages the use of the default
package?  (This is the message that appears when creating a new class
without specifying a package.)

Best Regards,
Josh
VisionSet - 02 Sep 2006 01:45 GMT
> I'm relatively new to Java and have been using Eclipse as my IDE.
> Would someone please explain why it discourages the use of the default
[quoted text clipped - 3 lines]
> Best Regards,
> Josh

To make name clashes more unlikely.
To enforce explicit importing again to prevent name clash.
Because the Java spec now forbids it (?).
Because many container framework specs and implementations of, do not
recognise default package classes - eg Tomcat.

--
Mike W
Patricia Shanahan - 05 Sep 2006 01:52 GMT
...
> Because the Java spec now forbids it (?).

The JLS says "Unnamed packages are provided by the Java platform
principally for convenience when developing small or temporary
applications or when just beginning development."
[http://java.sun.com/docs/books/jls/second_edition/html/packages.doc.html#35029]

They are not prohibited, and do have valid uses. For example, most
example and test code that I post in newsgroups is unnamed package, to
make it as simple as possible to run.

Patricia
VisionSet - 05 Sep 2006 16:59 GMT
> ...
> > Because the Java spec now forbids it (?).
>
> The JLS says "Unnamed packages are provided by the Java platform
> principally for convenience when developing small or temporary
> applications or when just beginning development."

[http://java.sun.com/docs/books/jls/second_edition/html/packages.doc.html#35
029]

> They are not prohibited, and do have valid uses. For example, most
> example and test code that I post in newsgroups is unnamed package, to
> make it as simple as possible to run.
>
> Patricia

Ah yes, thought there was a mention.

--
Mike W
Arne Vajhøj - 02 Sep 2006 01:51 GMT
> I'm relatively new to Java and have been using Eclipse as my IDE.
> Would someone please explain why it discourages the use of the default
> package?

It is bad structuring of your source code.

And your class is practically impossible to use
from other classes not residing in default package.

Arne


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.