Reputation: 43057
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?
Upvotes: 81
Views: 246894
Reputation: 1
To rename package in eclipse:
Upvotes: 0
Reputation: 11
I have tried this and quite Simple process:
Created a new Package with required name--> Moved all my classes to this new package (Right click on previous package --> Refractor--> Move)
Upvotes: 1
Reputation: 814
Right Click your Project
Android Tools>>Rename Application Package
Just Change Package in there...
Upvotes: 0
Reputation: 1
enter image description hereYou can open the class file in eclipse and at the top add "package XYZ(package_name), then while it shows error click to it and select ' move ABC.java(class_file) to package XYZ(package_name)
Upvotes: -1
Reputation: 11
select package name and sub package name both
press "save" a warning pop ups , press "continue"
name changed successfully
Upvotes: 1
Reputation: 1544
"AndroidManifest" file not changed for me and i change package name manually.
Upvotes: 1
Reputation: 11
Android app package name?
Just for the record, my case concerned an android app so if it concerns renaming the package name in an android application, then you can do it directly from the AndroidManifest.xml file, it's the first field in the android manifest, you change your package name and update it. Then if it shows you errors, so just "clean" your project in the "project" menu.
Upvotes: 1
Reputation: 851
In Eclipse Kepler/4.3 (and probably most other versions), you can:
A: Rename package in all files:
B: Rename src package:
Note that in each of the Replace... and Rename... dialogs leave all other defaults, unless you're selectively omitting renaming instances of the package name.
This procedure should automatically clean your project after each of A and B are completed (including the gen/ directory). But if you see any errors you should manually clean and rebuild ( , then select project, OK) to restore project elements integrity before proceeding. And you should immediately test the project to ensure this procedure worked before making further changes and confounding them.
Upvotes: 0
Reputation: 357
In pack explorer of eclipse> Single Click on the name of Package> click F2 keyboard key >type new name> click finish.
Eclipse will do the rest of job. It will rename old package name to new in code files also.
Upvotes: 1
Reputation: 2233
HOW TO COPY AND PASTE ANDROID PROJECT
A. If you are using Eclipse and all you want to do is first open the project that you want to copy(DON"T FORGET TO OPEN THE PROJECT THAT YOU NEED TO COPY), then clone(copy/paste) your Android project within the explorer package window on the left side of Eclipse. Eclipse will ask you for a new project name when you paste. Give it a new project name. Since Eclipse project name and directory are independent of the application name and package, the following steps will help you on how to change package names. Note: there are two types of package names.
1.To change src package names of packages within Src folder follow the following steps: First you need to create new package: (src >>>> right click >>>> new >>>> package).
Example of creating package: com.new.name
Follow these steps to move the Java files from the old copied package in part A to your new package.
Select the Java files within that old package
Right click that java files
select "Refactor" option
select "Move" option
Select your preferred package from the list of packages in a dialogue window. Most probably you need to select the new one you just created and hit "OK"
2.To change Application package name(main package), follow the following steps:
First right click your project
Then go to "Android tools"
Then select "Rename Application package"
Enter a new name in a dialogue window , and hit OK.
Then It will show you in which part of your project the Application name will be changed.
It will show you that the Application name will be changed in manifest, and in most relevant Java files. Hit "OK"
YOU DONE in this part, but make sure you rebuild your project to take effect.
To rebuild your project, go to ""project" >>> "Clean" >>>> select a Project from a projects
list, and hit "OK". Finally, you can run your new project.
Upvotes: 0
Reputation: 26084
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.
Upvotes: 119
Reputation: 242
com.myCompany.executabe is the path of executabe package. Here com,myCompany,executable are three different package. You have to manually rename individual package name you want to change.
Upvotes: 0
Reputation: 18712
Upvotes: 1
Reputation: 81
create a new package, drag and drop the class into it and now you are able to rename the new package
Upvotes: 1
Reputation: 3212
Just go to the class and replace the package statement with package com.myCompany.executabe after this eclipse will give you options to rename move the class to the new package and will do the needful
Upvotes: 0
Reputation: 14826
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.
Upvotes: 4
Reputation: 11221
Just create new package and move Classes to created package.
(default package) means that is no package.
Upvotes: 0
Reputation: 687
Try creating a new package and then move your files in there.
A short overview : http://www.tutorialspoint.com/eclipse/eclipse_create_java_package.htm
Upvotes: 0
Reputation: 24464
Select all files in the default package, right click -> Refactor... -> Move.. and select a package in the dialog or create a new one.
Upvotes: 0
Reputation: 3129
Create your directory structure in src folder like
.
means to create subpkg1 folder under pkg1 folder (source folder in eclipse) then place your source code inside and then modify its package declaration.
Upvotes: 0