How to change a package name in Eclipse?
In Eclipse I have a simple Java project that contains a package named (default package) and inside this package I have a class.
I want to rename this package into something like: com.myCompany.executable
I tried to select the (default package) ---> right click ---> refactor but now I see only the single voice named: Infer generic type arguments but not the possibility to change the package name.
Why? What have I to do in Eclipse to change the name of the package?
First you need to create package:
com.myCompany.executabe
(src > right click > new > package).
Follow these steps to move the Java files to your new package.
- Select the Java files
- Right click
- Refactor
- Move
- Select your preferred package
You can't rename default package since it actually doesn't even exist. All files in default package are actually in src
folder.
src--
|
MyClass1.java <==== These files are in default package
MyClass2.java
|
org
|
mypackage
|
MyClass3.java <=== class in org.mypackage package
Just create new package and move your classes within.