Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Delete default package(default package creation )
Delete default package [message #1604914] Sat, 07 February 2015 05:33 Go to next message
Dwight Norris is currently offline Dwight NorrisFriend
Messages: 16
Registered: January 2015
Junior Member
OK I am still a new B yes with a capital B
I have eclipse Luna fresh install

I read that Package names are important SO
when I create a new project I am presented with a src folder
that always has a default package created and name as such

This logic evades my to no end with all the preference settings
in eclipse you would think we would have a way to define the
Package Name at the time we create the Project

What am I missing here?
Please do not tell me to right click and delete the default package
I can create a Project with out the src folder but when the src
folder is created I still get the default package

If this is not an issue and I should just create another Package folder
under the src folder so be it

This still begs the question why show the default package in the Package Explore ?
Re: Delete default package [message #1605384 is a reply to message #1604914] Sat, 07 February 2015 13:14 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
If you create a class in a default package, JDT warns you "The use of the default package is discouraged".
This is for good reasons, because the concept of "default package" is oddly defined in Java and can confuse even seasoned developers.
OTOH, the package explorer shouldn't even show any default package UNLESS you create any classes in it (which happens if you miss to specify a 'real' package).
So, as a rule of thumb, whenever you create a new class ALWAYS declare a non-empty package and you'll never again be bothered by a default package.
Re: Delete default package [message #1605679 is a reply to message #1605384] Sat, 07 February 2015 17:52 Go to previous messageGo to next message
Erick Hagstrom is currently offline Erick HagstromFriend
Messages: 107
Registered: April 2014
Location: USA
Senior Member
I just created two new projects: a Java project and a Plug-in project. In neither one did I get a default package that just showed up by itself without me doing anything else.

The term "default package" just means the absence of a defined package. So, per Stephan's observations above, you probably went ahead and created a Class without giving it a package name. This takes some doing, since the New Class Wizard actually populates the "package" field with the name of the project under the assumption that that's probably what you wanted to begin with.

So you have several options here:
1) Create a new class with a proper package name. Eclipse will then create the package structure for you and you won't have to lift a finger worrying about packages.
2) Create the package you want, perhaps even with a package-info.java file in it. Then create a class inside it.
3) Continue using the default package and live with the shame. (Just kidding. That's not a very good option. But if you're just fiddling around it won't hurt too much.)

The reason Eclipse doesn't just ask you what to name "the package" is that there could well be more than one. It's quite common for a project to have several packages in it. So instead, Eclipse makes creating packages easy.

Welcome to Eclipse. Hope this helps.
Re: Delete default package [message #1605960 is a reply to message #1605679] Sat, 07 February 2015 22:27 Go to previous messageGo to next message
Dwight Norris is currently offline Dwight NorrisFriend
Messages: 16
Registered: January 2015
Junior Member
Thanks for the reply

I will do some more testing
Here is what happens for me
If I create a project I get a src folder with the obvious default package

This what I find silly
If I am a developer should I not know that I need a package name
hence my thought is create a project
then create the src folder
then add a package folder to the src folder

thanks
Re: Delete default package [message #1620548 is a reply to message #1605679] Tue, 17 February 2015 09:06 Go to previous messageGo to next message
Lorenzo johnson is currently offline Lorenzo johnsonFriend
Messages: 1
Registered: February 2015
Junior Member
Excellent info here I am currently doing some research and found exactly what i was looking for
Re: Delete default package [message #1622771 is a reply to message #1620548] Wed, 18 February 2015 18:41 Go to previous messageGo to next message
Dwight Norris is currently offline Dwight NorrisFriend
Messages: 16
Registered: January 2015
Junior Member
Well the best I can say is that Eclipse should rethink the concept
of default package

Here is how you hide the default package

from package explore if you look to the extreme right you will see
a small down arrow click it and select filters if you place a check
in the box next to Empty Packages the default package will be hidden

GREAT but there is more not so fast tidy house keeper
The issue is that when you create your own Package and of course
it will have nothing in it Eclipse also hides your new Package

This is a like a light switch to no light bulb
in my book it is poor design

If anyone from Eclipse reads this please feel free to advise me
on my new comer view of this IDE
I still like Eclipse but this design is flawed in my opinion
Re: Delete default package [message #1622961 is a reply to message #1622771] Wed, 18 February 2015 21:28 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
I don't think the problem is design, the problem is that you seem to observe an effect that has not been designed that way.

Quote:
If I create a project I get a src folder with the obvious default package


This is where we should find out what's happening.
When I create a new project the src folder does not show a default package.
The default package only shows up when I create a class in it.

What are your exact steps from project creation up-to observation of a default package in the package explorer?

Wait, I'm seeing a bug actually, a bug with a long history indeed:
- https://bugs.eclipse.org/bugs/show_bug.cgi?id=3544 (reported by Erich Gamma himself Smile )
- https://bugs.eclipse.org/bugs/show_bug.cgi?id=4989
- https://bugs.eclipse.org/bugs/show_bug.cgi?id=5073
- https://bugs.eclipse.org/bugs/show_bug.cgi?id=14763
- https://bugs.eclipse.org/bugs/show_bug.cgi?id=83334

Is that the problem you are seeing?

Stephan

Re: Delete default package [message #1622983 is a reply to message #1622961] Wed, 18 February 2015 21:48 Go to previous messageGo to next message
Dwight Norris is currently offline Dwight NorrisFriend
Messages: 16
Registered: January 2015
Junior Member
I create a new project this gives me a src folder and it has the default package created for me like it or NOT
my point is I do not want a default package created and if it is I want to be able to delete it
as I said before to me this seems like a way to make Eclipse friendly to New Users and the pros just bypass this step
OR I am missing a setting somewhere in Eclipse that would stop the default package creation
I would think it better practice to teach users you need to have a project Name a src folder and you add your package to the src folder
from here you need to know where to put a Class
So what I want to know is why FORCE the creation of the default package?
What happens when I add a package name to my code ?
as I said I am a new user but I have learned a way around the non sense
If I am not following good coding practice someone tell me PLEASE
thanks
Re: Delete default package [message #1623008 is a reply to message #1622983] Wed, 18 February 2015 22:05 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Quote:
So what I want to know is why FORCE the creation of the default package?


it doesn't happen (please *read* my previous post).

If it happens for you, it is a bug that only occurs on your machine, and we need your help in identifying what's causing it. So please:
"What are your exact steps from project creation up-to observation of a default package in the package explorer?"

[Updated on: Wed, 18 February 2015 22:07]

Report message to a moderator

Re: Delete default package [message #1625918 is a reply to message #1623008] Fri, 20 February 2015 18:21 Go to previous message
Erick Hagstrom is currently offline Erick HagstromFriend
Messages: 107
Registered: April 2014
Location: USA
Senior Member
Ok, Dwight, I get that you're frustrated and that the behavior you're seeing makes no sense. I agree, it makes no sense. The thing is, you're the only one who seems to be seeing it. So if you want to just vent about how stupid Eclipse is, fine, go ahead. But Eclipse is working from my perspective, so I'll just respectfully disagree and tune out from here.

If, however, you'd actually like some help in preventing or avoiding this onerous behavior, please respond to Stephan's request. You need to tell us exactly what you're doing. Which "new project" wizard (i.e. new java project? new plugin project? etc.), which options are checked, everything. Then someone can help you.

We want to help you. You have to participate.
Previous Topic:Add ear to server
Next Topic:Extension point for terminating process
Goto Forum:
  


Current Time: Wed Apr 24 15:23:26 GMT 2024

Powered by FUDForum. Page generated in 0.03806 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top