Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
229 views
in Technique[技术] by (71.8m points)

java - Renaming packages in Eclipse

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

package explorer filters

filters view
(source: eclipse.org)

You can then rename the com package and check the Rename subpackages option to force all child packages to be renamed.

rename package
(source: eclipse.org)

Then when you're done reapply the filter to hide all those empty packages again.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...