Reputation: 352
I have a lot of classes within a package and I have to move them to another package. I'm using Eclipse IDE and after moving them, I have this problem of editing each class file's first line (the "package" line)
For example, I have to change the line:
package abc.def.xyz;
to
package abc.def.hij.xyz;
is there a better way than to open each file and manually do it? I'm not a familiar with the IDE and I've looked around for a better way in Google but no solution yet. I have a lot fo things to move.
Upvotes: 1
Views: 7587
Reputation: 81
The error will come in case where you are manually moving classes directly to another package in your workspace.
Instead of doing this go to package explorer of your Eclipse IDE, I guess there will be multiple packages in your projectname->src folder(If it is simple java project type).
Now just select the java files from one package in your package explorer and drag them to target package.
Doing this will show a "Move" popup with auto selected checkbox "update references to classname.java", just press Ok.
This will just change the reference of your classes and you do not have to change the package name manually to all of your classes.
I hope this helped.:)
Upvotes: 7