24

In Eclipse's "Package Explorer", let's say I have a list of packages like this:

  • com.animal.dog
  • com.animal.cat
  • com.animal.frog

If I want to refactor this package structure so that the final package structure looks like

  • com.dog
  • com.cat
  • com.frog

So essentially removing the parent package & attaching the child packages to its grandparent. I have many child packages in "com.animal" package & I would like to avoid if possible doing this manually & then also changing the package imports everywhere.

2 Answers 2

36

If you switch your package representation to hierarchical (from arrow on the top-right), you can right-click the com.animal package and rename it to com.

1
  • I believe you've meant renaming to com (not animal). May 11, 2011 at 20:46
16

Probably you don't have any classes directly under com.animal. What you can do is either follow Bozho's suggestion (and switch to hierarchical view) or create a temporary class directly under com.animal. This way Eclipse would present a separate entry for com.animal.

Having selected com.animal you can simply do the rename refactoring. Make sure you select the 'Rename subpackages' checkbox. enter image description here

1
  • Thanks. this would have worked as well but I just switched to Hierarchical view as @Bozho suggested.
    – Chantz
    May 11, 2011 at 21:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.