Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
158 views
in Technique[技术] by (71.8m points)

java - Eclipse: change name of existing package with classes inside

In Eclipse, is it possible to change name of the package if it has name (default package) and has classes inside it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In the version of Eclipse I'm using (Indigo service release 1), the "Rename" option doesn't come up for the default package (unlike other packages) - but if you select all the classes then right-click and select "Move" that will let you put them in a new package.

(As far as I can tell, the Rename option is for renaming classes without changing their package, but Move certainly works for moving between packages.)

Screenshots of the process:

Original situation

Before

Select all classes and show the Refactor part of the context menu

enter image description here

Select "Move", click on Create Package and type in a name (mypackage in this case)

Move dialog

The final result

After

Alternatively, if you want to move them to an existing package, you could just drag and drop the classes.

For those suggesting Refactor -> Rename on the package, here's a screenshot showing that not working on my machine:

No Rename option


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...