• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Eclipse - add a new folder

 
bob reilly
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a Java application requiring modification. Viewing through Eclipse's Package Explorer, you can see the directory tree. I need to place a new folder in the middle of this directory tree. If you have folders "aaa.bbb.ccc" and "aaa.bbb.eee" but want to place another folder between them (ie. aaa.bbb.ddd) - is right clicking "aaa.bbb.ccc" to "New" ==> "Folder" and enterering the name going to do it (don't think this is it)? Or create a new folder on the source directory (that resides below the Project)? Are there other concerns?

By the way - as an alternative to using Eclipse - in a windows workstation envrionment - could simply enter a new folder name in the directory and after doing that, refresh in Eclipse?

Any comments / URLs would be appreciated. Thanks.
 
Paul Clapham
Sheriff
Posts: 20980
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Between" is a red herring because Eclipse will automatically arrange the folders in order for you.

And you don't want to create a new source folder, you want to create a new package in an existing source folder, right?

So my guess would be to right-click on the parent of the existing packages and select "New, Package".
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can create a folder using OS services (GUI or command line) and refresh an Eclipse project and it will show up, but it's easier to simply use the Navigator in Eclipse and skip the refresh.

As for "how to...?" why not try it and see? If you create a folder (or package level) in the wrong place, right-click on it, select Refactor/Move and move it to where you want it.
 
bob reilly
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the information. As far as trying things in Eclipse - you're right - but first I want my workstation backed up in the event I run into issues that I want to recover from.

One last question - after I create a new package in a src folder - and now want to create a new java source file to it. That's File >> New >> Class? After concerns here? Please bear with my newbie questions. Any URLs would be appreciated.

Thank you both for responding...
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Better yet, within the Package Explorer right-click the package you want to create the source file in and select New | Class. Then the New class dialog will be prefilled with the package name. Of course, you can always change the package name if you like.

Also, no need to backup the entire workstation - just zip up your project's directory (or make a copy of the directory). You can restore the project from that if things go horribly wrong.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter Johnson wrote:Better yet, within the Package Explorer right-click the package you want to create the source file in and select New | Class. Then the New class dialog will be prefilled with the package name. Of course, you can always change the package name if you like.


Helpful hint #1: Eclipse will often create multiple folder/package levels for you automatically. I always try that first just in case what I'm doing supports taking the easy way out.

Peter Johnson wrote:
Also, no need to backup the entire workstation - just zip up your project's directory (or make a copy of the directory). You can restore the project from that if things go horribly wrong.


Helpful hint #2: You can zip up (backup) a project by using the Eclipse export feature. For that matter, you can even make an unzipped backup using Export.

However, Undo/Redo are often available as well.

Eclipse really isn't all that fragile when it comes to stuff like this, so just play around with it until you feel confident that you know what it's doing.
 
bob reilly
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good informatin here - thank you.

One last question and I'm done. With the New Java Class - there's a section "Which method stubs would you like to create". There are 3 checkboxes. I can safely elminate the first - "public static void main(String[] args)". The second "Constructors from superclass" and third "Inherited abstract methods" - I doubt either are going to take place - however I'm looking to extend an existing package. What's the impact in checking or not checking? Can you revisit later and update this attribute option? That's it.

Thanks again for your responses.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the impact in checking or not checking?

If you check them, you get the indicated methods automatically when the class file is created. If you don't check them, you can always add them later - right-click within the source file editor window and select Source. Those two options, and many more, will show up in the submenu. If you do check them and decide you don't want the generated methods, you can easily delete them within the source file editor window.

I usually don't select the constructor option preferring to do that from the Source menu later. If I know that I am extending an abstract class or implementing an interface, I usually select the inherit abstract methods checkbox.

But try it both ways and see which one works the best for you. One of the nice things about the multitude of options that Eclipse provides is that you can adapt Eclipse to your way of working.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic