Contents (hide)

How to use Eclipse

This is a short tutorial on how to do basic things with Eclipse in the university's computer labs.

Start Eclipse

Press "Start" -> "All Programs" -> "Eclipse".

eclipse/runEclipse1.png

If you are asked to choose your workspace, choose the workspace "S:workspace",
and we advise to check "Use this as the default and do not ask again" checkbox.

eclipse/runEclipse2.png

Press the "Workbench" button.

eclipse/runEclipse3.png

Create a new project

Press "File" -> "New" -> "Project…".

eclipse/createProject1.png

Select "Java Project" (should be the first option), and press "Next".

eclipse/createProject2.png

In "Project name:" you need to enter the project name (in this example we create the project "LabAssignment").
Press "Finish".

eclipse/createProject3.png

Add existing file to the project

You need to drag the file to the project.
You should have both the File-Explorer and Eclipse open, and drag the wanted file from the File-Explorer to your project in Eclipse.
As a result, you will see that a "(default package)" is created under the project, and the file is added to it
(in this example we added the file "Main.java" to our project).
To edit the file, you need to double click on it.

Note: When dragging a file into Eclipse this file is copied. This means that when you edit the file in Eclipse, the original file does not change.
If you want to copy the file you are editing in Eclipse, please take a look at the "Copying a file from Eclipse" section.

eclipse/addExistingFile.png

Note: In newer versions of Eclipse (not the one in the labs), you need to drag the file to the src folder (inside the project -> (default package).

Create a new Java file in the project

Press the right mouse button on the project, and choose "New" -> "Class".

eclipse/addNewFile1.png

You need to set the new file name next to "Name:" (in our example: "NewFileName"), and press "Finish".

eclipse/addNewFile2.png

As a result, the new file will be opened.

Run a file

Press the right button on the file name you wish to run,
and choose "Run As" -> "Java Application".

eclipse/runFile1.png

If the file compiles okay, you will see the result in the console area on the bottom.

eclipse/runFile2.png

Close a project

Press the right button on the project name you wish to close, and press "Close Project".

eclipse/closeProject.png

Open (existing, closed) project

Press the right button on the project name you wish to open, and press "Open Project".

eclipse/openProject.png

Copying a file from Eclipse

In Eclipse, under the correct project, choose the file you want to copy (in our example Main.java).
Click the right mouse button (on the file) and choose "Copy".

eclipse/copyFile1.png

Then go to the File-Explorer to the directory where you want to save the file (in our example: S:New Folder).
Go to "Edit" -> "Paste".

eclipse/copyFile2.png

The file should be copied to that directory.

eclipse/copyFile3.png