Introduction to Eclipse


Until now, we've used DrJava throughout your computer science education. Although DrJava with its Interactions Pane is a nice IDE (Integrated Development Environment) for introductory purposes, it lacks many of the features found in professional quality IDE's, such as a good debugger and good large-scale project management capabilities. In this lab we introduce a powerful IDE called Eclipse which you will find to be a very useful tool, especially when working on large projects. Like DrJava, Eclipse is free and multi-platform (unix, Mac, Windows).

Advantages of Eclipse over DrJava

How to Set Up Eclipse

How to Run Eclipse

Working with Projects

Browsing a Project

Helpful Features While Coding in the Code Pane:

Running your code


The eclipse debugger is powerful. To learn it we'll debug, which contains a DebugLab class with a simple method and a very simple Useless class. We will set breakpoints (at lines of code where we want Java to pause during execution so we can examine the values of variables and so forth).
  1. Create a new project and create a new class called DebugLab in the project.
  2. Copy the contents of the< file to that class (or alternatively copy< to the directory of the project and refresh the project).
  3. You will set breakpoints to suspend the execution of your program. To add a breakpoint to any line in the code, press Ctrl+Shift+B while you are on that line. (Alternatively, choose Run -> Toggle Breakpoint from the menu.) For our purposes, add a breakpoint to the line that has the debug method.
  4. For debugging to work, you have to run your program in Debug mode. To do that you can press Alt+Shift+D, J or choose Debug As -> Java Application from the context menu. Once you run your program, it will execute up to first breakpoint it encounters and stop at that point, Eclipse will ask you to switch to Debug perspective automatically as it happens.
  5. Debug perspective contains a call stack at the top left corner, a summary of variables in top right corner. You can also get a list of breakpoints at the same place. At the bottom, you can see the console which will show any output.
  6. Our aim will be to analyze the values of Useless object u and the integer array a. There are several ways to do this:
  7. You also have different options to continue running your code. You can access the buttons explained below on the Debug pane.