aspose file tools*
The moose likes Beginning Java and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark ""The use of the default package is discouraged." Should I worry?" Watch ""The use of the default package is discouraged." Should I worry?" New topic
Author

"The use of the default package is discouraged." Should I worry?

T Dahl
Ranch Hand

Joined: Oct 07, 2010
Posts: 35
I have installed Eclipse to start my Java developement. My first impression is good.

Whenever I create a new class in Eclipse I get this message: "The use of the default package is discouraged.".

What does the message mean, and should I care? Am I doing something stupid?
Jeff Friesen
author
Ranch Hand

Joined: Sep 19, 2010
Posts: 41
Hi T,

The default package is the package where Java classes, interfaces, and other top-level types (such as enums) are stored when the source file in which the type is declared does not contain a package statement, such as package foo;.

Unlike small toy (and throwaway) programs, a large application's top-level types should be stored in packages to organize them and prevent name conflicts with another application's top-level types.

Eclipse is basically warning you that you have not specified a package in which to store your application's top-level types.

All the best.

Jeff


http://javajeff.mb.ca
T Dahl
Ranch Hand

Joined: Oct 07, 2010
Posts: 35
Thanks!

So, as long as I am toying around, learning and testing I could probably not do much harm if I ignore the warning.

When I develop my real application (which is hopefully not going to be very big) I could risk a name conflict, but only if there are other applications around. I guess these other applications has to import classes from my application before that becomes an issue?
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Also a class in a package can't access a class that is not in a package i.e. the default package.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
T Dahl
Ranch Hand

Joined: Oct 07, 2010
Posts: 35
Wouter Oet wrote:Also a class in a package can't access a class that is not in a package i.e. the default package.

That makes sense. I should set aside some time to learn how to work properly with packages. Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: "The use of the default package is discouraged." Should I worry?