Eclipse Tricks (for Java)
Thomas J. Kennedy
Vim (and to a lesser degree) Sublime Text are my editors of choice. Many students prefer an IDE that is configured out of the box. In general I recommend Eclipse. You might remember Eclipse from CS 252.
There are a few reasons I usually default to recommending Eclipse:
- It is introduced in CS 252.
- It is used in CS 350.
- It has plugins for C++.
- It has has plugins for Git.
- Git is good tool to explore in your free time (instead of watching TV).
1 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:
- Compiling and running a program with
./gradlew run
- Compiling and running unit tests with
./gradlew test
- 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.
2 Eclipse Import Instructions
To get started grab one of my Java examples or Java assignments.
-
Place a copy of a zip file in a memorable location (i.e., one you will remember).
-
Extract the zip file.
-
If your are on Linux or macOS:
- Open a terminal in the selected directory.
- Run
./gradlew eclipse
-
If your are on Windows:
- Open a Command Prompt window or Powershell Window in the selected directory.
- Run
.\gradlew.bat eclipse
-
Open Eclipse.
-
Go to
File -> Import Existing Project
. -
Select the directory you chose in Step 1.
3 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.