In Eclipse’s “Package Explorer”, let’s say I have a list of packages like this:
- com.dog
- com.cat
- com.frog
If I want to rename the “com” part of the package structure to be “animal”, then I could select each package (above) and perform a refactor > rename.
If I have many packages that start with “com”, that process may take a while. Is there an easy way to rename the “com” package name without having to individually rename each package in the Package Explorer? or removing those packages from the build path before renaming?
I tried going to the “Navigator” pane where it displays the folders in a tree structure but I am not given the rename capability.
By default empty parent packages are hidden in the package explorer, if you modify the Filters… in the Package Explorer to uncheck Empty Parent Packages (third from top in second screenshot) you’ll be able to see the empty packages.
(source: eclipse.org)
You can then rename the com package and check the Rename subpackages option to force all child packages to be renamed.
(source: eclipse.org)
Then when you’re done reapply the filter to hide all those empty packages again.