January 02, 2007 - Handy eclipse trick for importing classes into existing project

We get a lot of sample code that exhibits incorrect or unexplained behavior with AgitarOne - and many times we have to set it up in a debugger or import that code into an existing project. Recently I discovered that eclipse has a very easy technique for just this use case - thought I'll share it here.

It's a pain to create the package, then create a class, and then cut and paste the class code into the Java editor.

Instead, before discovering this trick i used to create any class (xxx.java) on the root, then cut and paste the class contents into the new java file, and finally use eclipse quick fixes to move it to the right package etc. 2 steps too many.

As it turns out the wonderful eclipse developers had thought about this. Once you've got the class text in the clipboard, simply select the project root in the package explorer and paste the class text there. Eclipse auto-magically creates the package etc. and adds the class to the right place in the source tree.

Neat! Makes me wonder what other tricks are hiding inside eclipse ... do you know any you'd like to share?

Posted by Ashish Kumar at January 2, 2007 11:14 AM

Trackback Pings

TrackBack URL for this entry:


Oh Lord!

There is several Tips and Tricks sections in the Eclipse's own help system. Check those in Workbench user guide and in JDT user guide.

Also it is good idea to read the "New and Noteworthy" pages for each release within few ears. It will feed you with lots of exiting news...

Posted by: Eugene Kuleshov on January 2, 2007 02:39 PM

Really great feature !!!!!
I could see the effort taken on user friendly point of view and technical also.

Posted by: Shrini on January 17, 2007 12:48 AM

Post a comment

Remember Me?