Skip to main content



      Home
Home » Newcomers » Newcomers » Changing a package name
Changing a package name [message #142589] Fri, 10 March 2006 11:45 Go to next message
Eclipse UserFriend
Yesterday I wrote a generic linked list. The eclipse workspace is called
"Linked List" and the package is called LinkedList.

Today I extended it to a doubly linked list and would like to rename
everything.

* I figured out how to rename the eclipse package -- go to the package
explorer, highlight "Linked List", click "File | Rename...", and rename it
to "DoubleLinkedList".

* Go to the the class files in other projects that use the package and
change "import fitch.LinkedList;" to "import fitch.DoubleLinkedList".

* Go to the package files and change "public class LinkedList" to "public
class DoubleLinkedList".

But then there's a question of renaming the file "LinkedList.java" to
"DoubleLinkedList.java". I'm wary of doing it from outside Eclipse
because IDE's get cranky when you start messing with files from outside
their interface.

The filename has to match the class name. How should I rename the file in
the case?

Secondly, I have another project named Geometry. There's a red box with
an "X" within the icon representing the project, indicating some kind of
error. However, the program runs fine, and when I expand the project in
the explorer, I can't find anything else that has the error icon.

Is there a way to find out what that error icon is trying to tell me?


Sorry for the stupid questions -- my IDE before this was vim. I feel like
a fish out of water. Thanks!
Re: Changing a package name [message #142644 is a reply to message #142589] Sat, 11 March 2006 12:06 Go to previous message
Eclipse UserFriend
Open up LinkedList.java in the Eclipse editor.
Click on the class name in the class declaration, eg.
public class LinkedList {
Right click, and select Refactor->Rename from the context menu.
Rename the class to DoubleLinkedList. Check the box that says Update
references.

It'll rename your class, your constructors, your file, and change the
imports and references to your class in any other java source files in
your workspace.

Renaming packages does the same thing if you select Update references -
you don't have to manually change all references in other code.

You can see what's wrong with your project by showing the Problems view
(Window->Show View->Problems). Errors should show up at the top of the view.

Hope this helps,
- Jeff
Previous Topic:String replace in all project
Next Topic:installing on Suse 9.3 64 bit
Goto Forum:
  


Current Time: Sun Jul 13 19:32:27 EDT 2025

Powered by FUDForum. Page generated in 0.11340 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top