Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extracting class in Eclipse

Tags:

java

eclipse

This must be possible but I just can't figure it out in Eclipse. I have

/** ClassA.java */
class A {
  ...
}

class B {
  ...
}

and I'd like to select class B and extract to its own file so that I get:

/** ClassA.java */
class A {
  ...
}

and

/** ClassB.java */
class B {
  ...
}

How do I do this in Eclipse?

like image 719
Ztyx Avatar asked Nov 01 '10 13:11

Ztyx


1 Answers

This is how you do it (works in Eclipse 3.5):

  1. Select your code to extract:

    /** ClassB.java */
    class B {
      ...
    }
    
  2. Cut

  3. Right click on the package in which you want to put it

  4. Select paste. (Then Organize imports if needed.)

like image 197
aioobe Avatar answered Feb 02 '23 06:02

aioobe