Resources‎ > ‎

Eclipse Tutorial

You might find the Basic Eclipse Tutorial screencast helpful.

Eclipse is an Integrated Development Environment (IDE).  An IDE is a program that provides the ability to edit, compile, and run source code.  Eclipse is one of the most popular IDEs for the Java programming language.    It is free and developed in Java.  Other popular IDEs include NetBeans and IntelliJ.

Installing Eclipse

  1. Visit http://www.eclipse.org/downloads/ and select Eclipse IDE for Java Developers.
  2. Download and install the software.

Eclipse on the Lab Computers

Eclipse is available on both the windows and linux partitions in the CS labs. 

Getting Started

  1. Launch eclipse.
  2. You will first be prompted to select a workspace.  Click Browse, and select the directory where you would like to store your work for CS 112.  It is recommend you use a directory such as coursework/cs112.  Eclipse will automatically create folders for each project (e.g., program) you create.
  3. Select OK.
  4. You will see a screen with several buttons.  Select the arrow
    which will take you to the workbench.  
  5. The Project Explorer box will list all of your projects.  The large editor box on the upper right will display your code.  The bottom right contains several tabbed panes to display error messages and also the output of your programs.

Creating a Project

  1. You will need to create a new project for each new program you write.
  2. Select File->New->Project.
  3. Click the arrow next to the Java folder, select Java Project and click Next.
  4. Choose a name for your project.  It is recommended that you use a name such as "Lab1" or "ConnectFour".
  5. Click Finish.
  6. Select Yes it if asks you to open the Java perspective.
  7. You should now see a folder in the Package Explorer pane with the name you choose for your project.
  8. If you navigate to the project folder from the command line (e.g., cd coursework/cs112/Lab1) you will see two subfolders: src and binsrc is where all of your .java files will be stored.  bin is where all of the .class files created by the compiler will be stored.

Creating New Classes

  1. If you click the arrow next to the folder in the Package Explorer you will see a src folder.  
  2. Right-click on the src folder and select New->Class.
  3. In the Name field, type the name of the class (e.g., Player).
    1. If you wish to use packages, type the name of the package in the Package field.
    2. If you wish to create a main method in the new class, select the box next to "public static void main(String[] args)".
  4. Click Finish.  A new class will appear under the src folder and the class will open in the editor box.  The basic framework for the class will be in place. 

Editing and Compiling

  1. Type your code in the editor window.
  2. As you type, Eclipse will automatically compile your code for you.  Errors are denoted with a red squiggly line and a red X to the left of the line on which the error occurs.  Clicking the X reveals suggestions for correcting the error.  You can also select the Problems tab on the bottom right and see more information about the errors in the code.

Running

  1. To run your program, you can do one of the following:
    1. Right-click on the project folder and select Run As->Java Application.
    2. Select Run from the menu bar.
  2. Output will be displayed in the Console tab at the bottom of the screen.  If the Console tab does not appear, select Window->Show View->Console.
Comments