Search code examples
netbeans-7

Rename Package with Sub-packages in netbeans


I Know this seems absurd to ask but I can't seem to get around renaming a package in Netbeans that Have sub-packages. ideally when I right-click and refactor > Rename it renames only the node on the Top. If I try to refactor the Next Node in Line, I get the Error that :

Package already Exists

Does anyone knows how i should go about renaming my main package containing other packages and sub-packages in Netbeans? I am using netbeans 7.2.1.


Solution

  • Using Netbeans 7.3 and assuming your project has the following structure:

    my.package.test.subpackage1
    my.package.test.subpackage2
    my.package.test.subpackage3
    

    You want to rename test into tests.

    Go to the NetBeans Files window (Ctrl + 2 or using the Window -> Files menu). Left-click on the folder corresponding to the package you want to rename (i.e. test). Type F2 and rename it.

    All the sub-packages should have been moved to the new directory and all the related package and import statements should have been updated.