How to import all classes at once in eclipse

In this post, we will see how to import all classes at once in eclipse.

Problem :

Sometimes you copy any java code from somewhere and you see many import errors. You go to each class and press ctrl + space to import each class one by one. Lets say you have large number of classes, you have to import each class one by one.

Solution:

Eclipse have provided organize imports feature which can import all classes at once and prompt you to select any class if there are multiple classes of same name present in classpath.
Right click -> source -> organize imports

Shortcut:

ctrl + shift + o

Lets understand with the help of example:

You can see, we need to import lot of classes. Just press ctrl + shift + o, you will see below screen.

Bingo!! you have resolved all import errors at once. I use this shortcut very often, I hope you find it useful.

Was this post helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *