Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2006

Tip: Looking for answers? Try searching our database.

Packages problem

Thread view: 
shiv - 16 Mar 2006 00:38 GMT
I have a sourcecode with the package hierarchy as
package1.package2.something. Can anybody tell me how can i change the
whole package into package3.package2.something ?how can i do this ?
Monique Y. Mudama - 16 Mar 2006 01:00 GMT
> I have a sourcecode with the package hierarchy as
> package1.package2.something. Can anybody tell me how can i change
> the whole package into package3.package2.something ?how can i do
> this ?

Lots of search and replace?

Not only do you have to move the files into the appropriate directory
hierarchy, you also have to change the package declarations at the top
of each file.

I did this recently.  Not terribly fun.
Signature

monique

Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html

Dimitri Maziuk - 16 Mar 2006 01:27 GMT
Monique Y. Mudama sez:
>> I have a sourcecode with the package hierarchy as
>> package1.package2.something. Can anybody tell me how can i change
[quoted text clipped - 8 lines]
>
> I did this recently.  Not terribly fun.

You know, that can be done in about 10 lines of perl. Or 50 lines
of ant. Or, if you're on unix, a simple shell script...

Dima
Signature

"Mirrors and copulation are abominable because they increase the number of
entities."                                        -- corollary to Occam's Razor

Furious George - 16 Mar 2006 06:43 GMT
> Monique Y. Mudama sez:
> >> I have a sourcecode with the package hierarchy as
[quoted text clipped - 12 lines]
> You know, that can be done in about 10 lines of perl. Or 50 lines
> of ant. Or, if you're on unix, a simple shell script...

You should be able to do in with 2 simple lines.

mv src/package1/package2/something/* src/package3/packag2/something
replace "package package1" "package packag2" --
src/package3/packag2/something/*.java

> Dima
> --
> "Mirrors and copulation are abominable because they increase the number of
> entities."                                        -- corollary to Occam's Razor
Roedy Green - 16 Mar 2006 01:43 GMT
On Wed, 15 Mar 2006 17:00:34 -0700, "Monique Y. Mudama"
<spam@bounceswoosh.org> wrote, quoted or indirectly quoted someone who
said :

>Lots of search and replace?
>
[quoted text clipped - 3 lines]
>
>I did this recently.  Not terribly fun.

Eclipse is a dream for this. Not only does it change the package
declarations, it fixes all the references.

Intellij is not quite as bright. It works only within one project.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Monique Y. Mudama - 16 Mar 2006 01:56 GMT
> Eclipse is a dream for this. Not only does it change the package
> declarations, it fixes all the references.

I still ended up having to do some explicit keystrokes in each file.
Or did I?  I ended up typing "ctrl+1" a few times for each file.

Signature

monique

Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html

Patricia Shanahan - 16 Mar 2006 04:30 GMT
>>Eclipse is a dream for this. Not only does it change the package
>>declarations, it fixes all the references.
>
> I still ended up having to do some explicit keystrokes in each file.
> Or did I?  I ended up typing "ctrl+1" a few times for each file.

The way I did this was to right click on the package name in the
"Package Explorer" window, and select Refactor-Rename.

I've also done it in a Perl script, before Eclipse got so good at
refactoring.

Patricia
Monique Y. Mudama - 16 Mar 2006 19:05 GMT
> The way I did this was to right click on the package name in the
> "Package Explorer" window, and select Refactor-Rename.

I may have run into trouble because I also had to move it within our
version control system, which is not so hot.  Now that I think about
it, that was probably the issue.

Signature

monique

Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html

IchBin - 16 Mar 2006 01:02 GMT
> I have a sourcecode with the package hierarchy as
> package1.package2.something. Can anybody tell me how can i change the
> whole package into package3.package2.something ?how can i do this ?

Just rename the package statement that is in each of your java program
files. Then put them into the new package dir structure you change it to.

Signature

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor,  Regular Guy (1952-)



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.