Rename Java Package in Eclipse

Today, I attempted to change a java package name. I did a right click at the package name and there’s no “Rename.”

What I did is creating a new package, say package.my.new. Then I go to package.my, right click > refactor> move and select package.my.new.

I then edited web.xml file, do a search replace from package.my to package.my.new and it works.

However, later I found that there’s a function “rename” under refactor. but I have not tried it. I will check it out next time.

Advertisements

5 Responses to Rename Java Package in Eclipse

  1. RorArelenoDen says:

    Great site this waoewaoe.wordpress.com and I am really pleased to see you have what I am actually looking for here and this this post is exactly what I am interested in. I shall be pleased to become a regular visitor šŸ™‚

  2. javarefinery says:

    The refactor functionality is handy because it will update all references at the same time, you can change the project quite freely. But of course it cannot update external referenes outside the eclipse workspace, like for example jsp pages or such.

  3. Excellent site, keep up the good work

  4. bwanamarko says:

    click on the arrow to expand your project, then src, and then package, e.g. com.me.myJavaApp. Right click on the package and select Refactor then rename, make sure that update references is checked. You can also try update textual references too.

    This worked for me,

  5. steve donato says:

    In eclipse “JUNO” refactor has NO rename option only has one option, which is; “infer generic type arguments’ option” so how do I do it? Old version of eclipse use to have rename option? now it’s gone.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: