Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rename Package with Sub-packages in netbeans

Tags:

netbeans-7

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.

like image 827
Stanley Mungai Avatar asked May 25 '13 06:05

Stanley Mungai


People also ask

How do I Rename a Java source package?

In the Project Explorer, right click the package name and choose Refactor->Rename.

How do I Rename a spring boot package?

Right-click the package you want to move, and select " Refactor/Rename..." -- NOT " Move "! Modify the name of the package to reflect its desired new position in the package hierarchy, e.g.

How do I Rename a variable in NetBeans?

To rename a variable, method or class name, consider the following steps: Click right on the variable/method/class name and select "Rename" from the Refactor menu.


1 Answers

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.

like image 131
Marc de Verdelhan Avatar answered Nov 09 '22 18:11

Marc de Verdelhan