Eclipse Tutorial for ITC129

Trevor Ian Peacock, 28 October 2003

Eclipse an IDE (Integrated Development Environment) that supports the development of java programs, providing features that make programming java programs easier and more time efficient. Eclipse is designed to support the needs of a professional programmer, and thus has many features that ITC129 students do not require. With all these additional features finding the features that you actually do need can be a little difficult. This tutorial addresses these difficulties and introduces features useful to a Java student.

 

Installation

Here are a few links from the official Eclipse site:
Official Site - http://www.eclipse.org/
Download Page - http://www.eclipse.org/downloads/index.php
Direct Download Links - http://eclipse.planetmirror.com/downloads/drops/R-2.1-200303272130/eclipse-SDK-2.1-win32.zip http://mirror.pacific.net.au/eclipse/eclipse/downloads/drops/R-2.1-200303272130/eclipse-SDK-2.1-win32.zip

Be warned, the download is about a 70Mb download, so if you know someone who has it already, it could save you the download.

There is a newer version, but the links above are the version used in this tutorial (version 2.1) although the newer one (2.1.1) should be virtually identical.

There are also versions of eclipse for Linux and Mac OS.

The download is a zip file. Unzip the file using your favourite zip program, then the folder, find eclipse.exe and run it. Eclipse does not need to be installed, it will run directly from the unzipped folder.

Eclipse may take a little minute to start, but upon running eclipse you should see something that looks like this.

You can close the welcome screen by hitting the "X" on the Welcome tab.

To begin using Eclipse go File -> New -> Project. Click next to create a Java Project. Give the project a name, then click Finish.

Eclipse may ask you "This kind of project is associated with the Java Perspective. Do you want to switch to this kind of perspective now?" Answer "Yes" to this question and Eclipse will arrange the display for Java editing. You may also check "Do not show this message again".

You should now see your new project appear on the left under the "Package Explorer".

To create a new class go File -> New -> Class. Give the class a name under the "Name:" field, and click finish (note there are also options on the bottom of this window for automaticlly including a main method or constructor methods). Click Finish and let eclipse churn away creating your class. When it has finished, your new class should also appear under the "Package Navigator" and your class will be opened for editing.

Now its time for a quick introduction to the Eclipse "Java Perspective".

Along the top we see the normal type menus, followed by a toolbar. The First icon is the "new" () icon, it can be used to create new projects and classes (rather than going File->New). Next is the "Save" icon which simply saves the current class. It may also be useful to save all classes you are working on. To do this go File -> Save All, or use the shortcut key Ctrl + Shift + S. A little further along is the normal print icon, followed by the two more important icons. The first being the "Debug" icon (the little bug icon) and the "Run" icon (), which we will use shortly. Also further on are some forward and backward icons. These can be used to jump back and forward through an open file, to the last part you edited. Experiment with these later, it can make working on a large file (like the ones in the assignment) easier and quicker. Further on are some up and down arrows which can be used for jumping to errors in your files.

Down the left side is are the different "Perspectives". We can use this later to switch between the "Java Perspective" and the "Debug Perspective".

The package explorer lists all projects and their files. It also lists other items, such as packages used, but we need not concern ourselves with these.

The main editing window is where we work on our files. It features tabs at the top to allow multiple open files.

The Outline on the right hand side lists all the methods and variables in a file, by clicking on an item, Eclipse will jump to the section of code where that item is defined. Have a play with this later.

Lastly the bottom section lists all errors and warnings in your code, it also shows TODO items. These can be added by making a comment with "TODO" written in it, for example You can double click on items in this box to jump to that section of code.

Next Section: Completing and Running the Example Program