Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicate .java file in Eclipse

I'm looking for something like the refactoring function in Eclipse but for copying files, i.e. I want to keep the existing file, but add another one (typically an enum or similar).

Currently I do this by manually copying the file in the file system, then refreshing the folder in Project Explorer, then opening the file through Project Explorer, then search 'n replace, then I can start working. It can be a bit tedious as I often do this for 10+ files when I add a new major feature.

like image 564
Jonas Byström Avatar asked Jun 14 '12 12:06

Jonas Byström


2 Answers

In an Explorer view, select a file, right click and choose Copy. Now select the folder it's in, right click and choose Paste. You'll get a dialog asking for a new name, and you're done. Note that if you do this to a Java class, the new name will be used to rename the class in the file as well.

like image 139
Ernest Friedman-Hill Avatar answered Sep 30 '22 07:09

Ernest Friedman-Hill


You can copy and paste files within the package explorer of Eclipse.

like image 20
Autar Avatar answered Sep 30 '22 09:09

Autar