• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
author
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
T Dahl
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also a class in a package can't access a class that is not in a package i.e. the default package.
 
T Dahl
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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!
 
These are the worst of times and these are the best of times. And this is the best tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic