How do I import a Git project into Eclipse?

The following guide shows you how to import the cloned repository into Eclipse IDE
Note that this guide only applies to Gradle projects. Other projects may have different steps

  1. Launch Eclipse and wait for it to load (Setup the workspace and close the Welcome screen if it pops up)
  2. Click on File > Import

    How do I import a Git project into Eclipse?

  3. Select Gradle > Existing Gradle Project and click Next

    How do I import a Git project into Eclipse?

  4. Enter the root path of the project directory and press Next

    How do I import a Git project into Eclipse?

  5. Continue spamming Next until you cannot do so, then click Finish

    How do I import a Git project into Eclipse?

  6. Note: If you receive this error as shown in the picture below, ignore it and press OK

    How do I import a Git project into Eclipse?

  7. The source files can be found in src/main/java

    How do I import a Git project into Eclipse?

  8. To run the program just press the Green Play button in the Toolbar as per normal

Demo Video
The following is a video on how this is being done. Read the how-to guide before watching the video for actual steps to do it

Your browser does not support video files^
Back to
Top

Follow these steps to import an Eclipse project from your Github repository. These steps assume you have already followed the Configuring SSH Keys and Java and Eclipse Setup guides.

Import Repository into Eclipse

You first need to add the Github repository to Eclipse. Log into Github and open Eclipse, and follow these steps:

  1. Copy the SSH link to clone your repository in Github. Make sure you are getting the SSH link, not the HTTPS or HTTP links.

    How do I import a Git project into Eclipse?

  2. Switch to Eclipse and open the “Git Perspective” (Help). Select “Window” » “Perspective” » “Open Perspective” » “Other” from the menu, and then “Git” on the dialog box.

    How do I import a Git project into Eclipse?

    Click the “Open” button. The “Git Perspective” should look similar to this:

    How do I import a Git project into Eclipse?

  3. Click the “Clone a Git repository” button or link. (You can hover over the buttons to see their descriptions.) This should open the following dialog window:

    How do I import a Git project into Eclipse?

    The fields should automatically fill in based on the link you copied in Github. (If not, hit cancel, copy the link, and then re-open the dialog window.)

  4. Click the “Next” button, make sure the master repository is selected, and click the “Next” button again. If you are storing your CS 212 code in a specific folder, click the “Browse” button and select it in the following dialog window:

    How do I import a Git project into Eclipse?

    Follow the prompts to finish the process.

  5. You should now see the repository listed in the Git Perspective:

    How do I import a Git project into Eclipse?

    You can right-click the repository to access several git actions, including the “Pull” action which you will need to keep this local repository (on your system) synchronized with your remote repository (on Github).

You only need to add this repository once, even if there are multiple Eclipse projects within that repository. For example, you only need to import the lectures repository once. However, since each homework assignment has its own repository, you will have to import each repository separately.

Import Projects into Eclipse

Before you start, double-check that you have the latest version of the remote repository by performing a “Pull” action (Help).

Now that the repository is added to Eclipse and up-to-date, you can import the Java projects from that repository into Eclipse using these steps:

  1. In Eclipse, select “Import…” from the “File” menu.

    How do I import a Git project into Eclipse?

    Select “Projects from Git” in the dialog window and click the “Next” button.

  2. Select “Existing local repository” and click the “Next” button. Select the repository in the next dialog window.

  3. Make sure to select “Import existing Eclipse projects” in the dialog window:

    How do I import a Git project into Eclipse?

    Click the “Next” button to continue.

  4. Make sure the projects you wish to import is selected and click the “Finish” button. Some projects may be greyed out if they have already been imported into Eclipse previously.

  5. Double-check the project setup and try running the code. If you see errors, use the troubleshooting steps below. Otherwise, your project is ready!

Troubleshooting

If you notice several errors, it is likely something isn’t quite right with the build path setup for your Eclipse project. This happens when your setup is different from expected (either you have a different version of Eclipse, Java, or named your third-party libraries differently).

To fix this, right-click your project folder and select “Build Path” and “Configure Build Path” from the menus. On the following window, click the “Libraries” tab. Remove everything that has a red “x” icon or is listed as “unbound” in the label.

Now, we have to re-add the necessary libraries. Click the “Add Library…” button and follow these steps:

  • Select “JRE System Library” to re-add Java 13 (if necessary). I recommend you select “Workspace default JRE” unless the default is NOT Java 13.

  • Select “JUnit” to re-add JUnit 5 (if necessary). Make sure “JUnit 5” is selected in the dropdown, not JUnit 4.

  • Select “User Library” to add a third-party user library (if necessary). This could be log4j2, Apache Commons, etc. depending on the assignment. See the Adding User Libraries in Eclipse guide for more details on how to set those up.

Click “Apply” and “OK” when done. You should see all of the scary red icons disappear. If not, ask on Piazza or during office hours for help!

Video Walkthrough

This video walkthrough will illustrate this entire process on a Mac OSX system. Alternatively, you can follow the steps in the sections below. This is an older video—some steps may not align perfectly.

How do I Import a Git project?

Importing Using the New Project Wizard.
Click File > Import ..
In the Import wizard: Click Git > Projects from Git . Click Next . Click Existing local repository and then click Next . Click Git and then click Next . In the Wizard for project import section, click Import using the New Project wizard . Click Finish ..

How to add a project to Git repository in Eclipse?

Create a local Git repo for your Eclipse project With your project open in Eclipse, right-click the project name in Project Explorer and select Team, Share Project... Select Git and select Next. Select Create... from the Configure Git Repository window and choose a folder for your local Git repo. Select Finish.

How do I Import an entire project into Eclipse?

Importing an Eclipse Project.
Open File->Import..
Select "Existing Projects into Workspace" from the Selection Wizard..
Select Next to get the Import Wizzard. Browse to find the location of the Project..
Make sure the Project you want is checked, then hit Finish..