Eclipse Tricks (for Java) & VSCode

Thomas J. Kennedy

Contents:

1 Stick with VSCode

In general, I recommend that students use VSCode, if they already have:

  1. VSCode configured on their machines.
  2. Remote development set up to use the CS Linux servers.

2 Why Mention Eclipse?

Vim (and to a lesser degree) VSCode are my editors of choice. Many students prefer an IDE that is configured out of the box. Eclipse is an okay Java IDE.

In general I recommend Eclipse. You might remember Eclipse from CS 252.

There is now only one reason that I sometimes recommend Eclipse:

  1. It has has plugins for Git.
    • Git is good tool to explore in your free time (instead of watching TV).

3 Using Gradle with Eclipse

In my Gradle build scripts (i.e., build.gradle) you will find lines in the form:

apply plugin: "java"
apply plugin: "application"
apply plugin: "eclipse"

or


plugins { id "java" id "application" id "eclipse"

These lines are followed by settings for:

  1. Compiling and running a program with ./gradlew run
  2. Compiling and running unit tests with ./gradlew test
  3. Generating an Eclipse project with ./gradlew eclipse

It is the last Gradle task (i.e., eclipse) that interests us. This allows us to skip the manual setup of a Java project.

4 Eclipse Import Instructions

To get started grab one of my Java examples or Java assignments.

  1. Place a copy of a zip file in a memorable location (i.e., one you will remember).

  2. Extract the zip file.

  3. If your are on Linux or macOS:

    1. Open a terminal in the selected directory.
    2. Run ./gradlew eclipse
  4. If your are on Windows:

    1. Open a Command Prompt window or Powershell Window in the selected directory.
    2. Run .\gradlew.bat eclipse
  5. Open Eclipse.

  6. Go to File -> Import Existing Project.

  7. Select the directory you chose in Step 1.

5 Eclipse Video

I have created a few Eclipse lectures for other courses. One video, Setting Up A Java Project, covers the basics of setting up a Java project.

Jump to time 20:28 if you are using the ./gradlew eclipse import method.