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.

Related Posts

  • 16 January

    How to create simple java project using maven in eclipse

    In this post, we will see how to create a simple java project using maven in eclipse. We have already seen before how to create dynamic web project using maven in eclipse. I am using following tools for this post. eclipse-jee-mars-R-macosx-cocoa-x86_64 Apache tomcat 8 m2eclipse plugin jdk 1.7 Steps for creating dynamic web project using maven […]

  • 05 September

    How to create dynamic web project using maven in eclipse

    In this post, we will see how to create dynamic web project using maven in eclipse. If you can also create simple java maven project in eclipse. I am using following tools for this post. eclipse-jee-mars-R-macosx-cocoa-x86_64 Apache tomcat 8 m2eclipse plugin jdk 1.7 Steps for creating dynamic web project using maven in eclipse. 1) Install m2eclipse […]

  • 04 September

    How to install maven plugin(m2eclipse) in eclipse

    Apache maven is a build automation tool used for java projects. It is widely used for building java projects now a days. In this post, we will see how to install m2eclipse maven plugin for eclipse. Steps for installing m2eclipse plugin in eclipse: 1) goto Help->Install new software.  2) Click on add to add m2eclipse […]

  • 17 July

    How to configure Apache Tomcat in eclipse

    Table of ContentsStep 1:Step 2:Step 3:Step 4 :Step 5:Step 6:Step 7: In this post, we will see how to configure apache tomcat in eclipse. As per wikipedia, Apache Tomcat, often referred to as Tomcat, is an open-source web server and servlet container developed by the Apache Software Foundation (ASF). Tomcat implements several Java EE specifications […]

Leave a Reply

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

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.