CSCI1260 Introduction to Computer Science II
Homework 0 – Nothing to Submit for Grading
Using Eclipse IDE

Creating a Workspace

1.  Launch Eclipse, and the very first dialog you should see is one asking you to select a workspace:

A workspace is simply a folder that stores all your projects. Each project in turn is stored in a separate subfolder within the workspace.

2.  Select “Browse…” This allows you to either select an existing folder or create a new one as your workspace.

3.  Create a workspace folder called something like “CSCI1260_Workspace” on a USB drive or other drive to which you have read/write access throughout the term. Do not try to create it on the C:\ drive in the lab because nothing may be stored there permanently.

4.  After specifying the workspace folder, select OK to go to the Eclipse Interactive Development Environment (IDE). If the workspace is new, you’ll see the Eclipse welcome screen:

If you wish, you may select the various icons and browse the information provided there.

5.  However, we will click the ‘x’ in the tab to close the welcome tab. You should then be presented with the Eclipse work area:

6.  Spend a minute or two identifying these areas (In Eclipse, they are called views):

·  Package explorer: all your projects and classes will be visible here.

·  Main Editing Area: The file that you are currently editing will be visible here.

·  Problem Reporting Area: This is one of the many tabs that will appear here. This tab shows any warnings and errors that are currently in your project.

Creating a Java Project

7.  Create a new Java Project called something like “HelloWorld”. To create a project, select the File menu, then New, and then Java Project.

File > New > Java Project

You will then be presented with the project creation dialog. Take note of the settings, then enter your project name, and then select Finish.

After pressing Finish above, the project name now appears in the Package Explorer area of Eclipse. There is not yet any code to edit in the editor area, and there are no error messages present in that area.

After you create the project, it will be ‘Open.’ Take note of the shape of the folder icon beside the project name.

Closing a Project

8.  Close the project. You can ‘Close’ the project by right-clicking on the project name and then selecting ‘Close Project.’ Notice how the icon changes after closing the project.

Opening a Project

9.  After closing the project, exit Eclipse completely and then re-launch it.

10.  When prompted select the workspace that you’ve just created. Note that the HelloWorldApp project still exists.

11.  Open the project. To open the project, right-click on it and then select ‘Open Project’ or double click on the project name.

Creating a Class

12.  Create a class called something like HelloWorldApp by following these instructions: After opening the project, click on the little triangle that is to the left of the project name to expand the project folder. Take note of the src folder. The src folder is the source code folder and will contain all your Java source files for this project.

Let’s now create a main (or driver) class. Right click on the src folder and then select New > Class. You will then be presented with the New Java Class dialog.

Te

nter the name of the class, in this case HelloWorldDriver. Since this is a driver class, check the ‘public static void main (String [ ] args)’ checkbox. Check the ‘Generate comments’ checkbox so that Eclipse starts the Javadoc for you. Select ‘Finish’ when ready.

Eclipse will create the Java source file and startup code for you.

13.  You can now complete the simple ‘Hello World’ program by replacing the TODO comments with code to display “Hello, world!” on the console as shown above.

14.  Click on the disk icon to save the file. Always save your files after you make a change.

Running the Main Class

15.  Run the main class by following these instructions: right-click on the file name and then select: Run As > Java Application.

When the program runs a new tab called ‘Console’ appears and the output of the program is displayed there.

That’s it; you’ve completed your introduction to using the Eclipse IDE. Please spend enough time reviewing how to:

·  Launch Eclipse

·  Create a workspace

·  Create a Java project

·  Close a project

·  Open a project

·  Create a class

·  Run the main class of the project.

The Project Folder

After completing the above tutorial, minimize or exit Eclipse. Use your operating system user interface to navigate to your workspace folder. Here is mine:

Note that there’s a “.metadata” folder there. That folder is very important to Eclipse so don’t delete it. Eclipse uses it to store information about the workspace and about the various projects in that workspace. Note also that there is a ‘HelloWorldApp’ folder. That folder stores the files of the HelloWorldApp project. Navigate to it.

In the HelloWorldApp folder there is a .settings folder, a bin folder, a src folder, and two additional files: .classpath and .project. Do not delete or modify these files and folders because Eclipse needs them. The src folder contains your source code (i.e., your .java files) while the bin folder contains the compiled byte code (i.e., your .class files). You can navigate to them to see the files.

There is nothing to submit for this exercise.