Informatik 1 – Schmiedecke

Lab exercise X1 – IDE-al Java: Eclipse


Objective: Become familiar with the eclipse workbench for java.

Hint: You will be using eclipse to locate and fix errors in a given program. It is the process of error finding that matters – so telling each other where to find them is not really helpful.

Hand in: Lab report

Set up your report to become your personal eclipse handbook. You are encouraged to add to it during the term.



  1. What does IDE mean?
  2. About Eclipse
  3. Lab experiments
  4. Where do I Find Help?


What does IDE mean?

IDE means integrated development environment. An IDE encompasses all basic programming tools, i.e. it allows you to switch between editor, compiler and  executer, without leaving the IDE.  Usually, an IDE contains many other tools as well, like versioning tools, modelling tools, etc. The term "eclipse workbench" suggests just this: you do all your programming work from the eclipse user interface.

You will certainly appreciate the cooperation between editor compiler and even run time system: a double click on the error message takes the editor to the error position.


One major advantage of using an IDE is that you work in "projects". Each project has its own libraries and classpath settings etc. The IDE remembers these settings, so that when you open an existing project, the IDE sets up its proper environment. This saves a lot of work, and more important, errors!


About eclipse

Eclipse is an open source development tool now owned IBM. You can download it from the eclipse homepage – where you will also find a great number of so-called plug-ins, i.e. additional tools that can be added to eclipse. Choose eclipse for Java Developers; you don't need JEE yet.

Eclipse is written in Java and for Java – although there are now many plug-ins for other languages. Later on, you might be contributing to the eclipse development…


Eclipse comes with a set of tutorials (on the Welcome page) . If you find it difficult to follow the lab steps, follow the Hello world tutorial to get started.  There are also a lot of tutorials in the internet, just ask google about it if you want to find out more.


Lab experiments

In this lab, you will walk through the general program development cycle in eclipse – except for the initial program design. Instead of writing your own java program, download and save them on your computer (make sure they has the file extension .java).


Step 0: Set up a Hello World Project:

1.      Start Eclipse and open a new Java Project, call it Hello. Make sure to set up your workspace in Z:….this is where Eclipse will store all data.

2.      Write another little HelloWorld program:

1.      If everything is fine, you can now run your program: Right click on your HelloWorld class and select "run – as java application". (Throughout this semester, we will only be working with "applications").

Otherwise fix your syntax errors first.

3.      You should see the output in the console below your editor.

Step 1: Set up another Project

1.      Open another Java project, call it MyEuclid.

2.      Now import (i.e. copy) into your project, right clicking on your project and choosing file>import>from file system

3.      Double click on Euclid in your package explorer (left hand side). The program is opened in the Eclipse editor.
You see syntax highlighting  - and a lot of error markers: In Eclipse, the compiler cooperates with the editor, so that many syntax error are discovered immediately on input. In order to get a  deeper compiler check every time you save a file, check "Build Automatically" in the project menu. "Building" a program means compiling and linking it.

4.      Read the program and try to understand how it is supposed to work – adding some comments, if you like.


Step 2: Set up your Project Environment

Just like Eliza, Euclid needs the library cs101-lib.jar. In the command shell, we would need to add it to the CLASSPATH.


The equivalent of the CLASSPATH system variable in Eclipse is the "Java Build Path" in the project properties menu. Open the "Java Build Path" tag and select "Add External Jars" in order to add the library to the project classpath.


(As a partial equivalent of the PATH system variable, you can choose the "Java Compiler" tag and change the compiler version to be used.)


Step 3: Remove Syntax Errors

Now begin to deal with the error markers. As the compiler works top-down, you should also begin at the top.



Example: The first marker you meet will read "Console cannot be resolved". Quick Fix suggests "import" or "import cs101ext.Console" – choose the latter one, and many markers will disappear, at least after saving the changes.


Carry on till all markers are gone. Hopefully, you have made the right fixes….


Step 4: Debug

Now run your program, using again "run – as java application".


Now, it is time to learn debugging.  Remember, a debugger is a program that allows you to watch – and even influence – a running program. Watching really means controlled stepwise execution and the possibility to read, and even modify, variable values at any given time. You can also watch the call stack andsome other features, but that needs to be left for later on…


Eclipse has such a debug tool, and you are to use it to locate and modify the semantic "bugs" I put into this little program, following the debugging istructions or the eclipse debug tutorial.


 After you finish, try to debug – it is a little harder, so this is part of the voluntary work of the lab, i.e. it is not required, but good for extra points.



For Fast Workers: Using Jar Files

2.      Start eclipse and open a new Java project, call it JavaEyesJar.

3.      Add javaeyes.jar as an External Jar to your Java Build Path. When you download it, check the file extension and change it back to .jar, if necessary.

Now try the three ways to start a program in eclipse:

4.      Start the program using the Run menu: Run>Run as.. choosing Java Application.

5.      Now find "JavaEyes.class" in the package explorer on your left hand side. Right click on it and select "run as Java application".

6.      Start the program through Run/Run… . In the Run window, choose New Configuration, and type in JavaEyesJar as project name and javaeyes.JavaEyes as main type (i.e. class containing the main method)




Where do I get Help?

There is an offical Java documentation, which you should always have at hand: 
there are also some very useful tutorials


The cs101-Library:
There is an online
Documentation* For downloading, I suggest cs101-src.jar*, which contains the documentation.

Use the Help Menu, or find tutorials with google.



Google seems to know a lot about java programming – even strange error messages will lead you to fora discussing solutions...
When you are in the lab, you will be surrounded by people having similar problems. Some of them might already have solved yours....

©: Ilse Schmiedecke 2008 – For questions and comments contact