Moving packages eclipse
Maybe a stupid question bu开发者_如何学Got I have two packages in eclipse and now I would like to move the one package into the other for better structure.
Now I tried move but that generates a copy into the same package.
And with refactoring -> move I even can't select the packages
Can anyone help me....
thx all
If you have com.company.foo
and com.company.bar
, and want to move foo
into bar
, then just rename com.company.foo
to com.company.bar.foo
.
If you package happens to have subpackages, tick Rename subpackages
to move the subpackages as well.
Use the package explorer view and rename the package. It asks for renaming updating references, renaming sub packages, update textual references in comments and and also non-Java text files. Click on the preview and then ok.
I have found the solution, when you rename a package to the desired destination, check on the box "rename subpackages" and there you go! :) – user1525788 Jul 10 at 9:14
if you have current package:
- com.insect.fly
and would like to add subpackage to it, then renaming will solve the purpose e.g.
- com.insect.fly.mosquitto
However, eclipse do not should it in nested style. Just do Package Explorer > click on v button on the pane next to minimize > package presentation > Hierarchical
Hope that SOLVES !!
This is slightly non-intuitive, but the best way to do it is by right clicking on the package you wish to move, clicking on refactor
, and then on rename
.
Then proceed to enter the fully qualified path which you desire.
For example, if you wish that a package called dog
be moved into a package called mammals
which itself is in a package called animals
you would essentially rename your dog
package to animals.mammals.dog
In other words, the package structure
is represented as animals.mammals.dog
in the world of Java packages, and a renaming achieves the desired effect.
Please note that you must not try to achieve this by manually moving the folders in Windows explorer. These actions are best done using your IDE.
this is rlly old but try opening in hierarchy mode. in project explorer click the small arrow (pointing down) > package presentation > hierarchical.
精彩评论