In Eclipse, is it possible to change name of the package if it has name (default package)
and has classes inside it?
Right-click the package you want to move, and select " Refactor/Rename..." -- NOT " Move "! Modify the name of the package to reflect its desired new position in the package hierarchy, e.g. Prepend any new parent package name(s) if you are moving the package to downwards in the package hierarchy.
Simply select the class, right click and choose rename (probably F2 will also do). You can also select the class name in the source file, right click, choose Source, Refactor and rename.
In the version of Eclipse I'm using (Indigo service release 1), the "Rename" option doesn't come up for the default package (unlike other packages) - but if you select all the classes then right-click and select "Move" that will let you put them in a new package.
(As far as I can tell, the Rename option is for renaming classes without changing their package, but Move certainly works for moving between packages.)
Screenshots of the process:
Original situation
Select all classes and show the Refactor part of the context menu
Select "Move", click on Create Package and type in a name (mypackage in this case)
The final result
Alternatively, if you want to move them to an existing package, you could just drag and drop the classes.
For those suggesting Refactor -> Rename on the package, here's a screenshot showing that not working on my machine:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With