java – How to change a package name in Eclipse?

java – How to change a package name in Eclipse?

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.

  1. Select the Java files
  2. Right click
  3. Refactor
  4. Move
  5. Select your preferred package

You cant rename default package since it actually doesnt 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.

java – How to change a package name in Eclipse?

Press Alt+shift+R key and change package name

Leave a Reply

Your email address will not be published. Required fields are marked *