CS61B: Using Eclipse in Windows


Eclipse is the IDE (Integrated Development Environment) that we will be using to write and execute Java programs. It is available to multiple platforms. Here are the instructions for installing Eclipse and anything else that you need for this class.

Install the following tools before getting started:

  1. JDK 1.6. The current release of JDK (Java Development Kit) is 1.6. It is made available by Sun. There are different updates, and you only need to install the lastest update (update 7 at the time when this page is written). It can be downloaded from here: Java SE Downloads. Choose "JDK 6 Update 7" to download and select your operating system in the new page. Install it after downloading. If you choose the default path for the installation, please verify that javac.exe and java.exe are available at C:\Program Files\Java\jdk1.6.0_07\bin. If the installer has not added the above path to your environment, add it in the "Properties" dialog from "My Computer".

  2. Eclipse 3.4. Eclipse is available at the Eclipse download servers. From the several available packages, please choose Eclipse IDE for Java Developers (85 MB). Select the nearest server in the new page. The downloaded file has name "eclipse-java-ganymede-win32.zip". Extract to a path that you like, say C:\CS61B, and you will see a subdirectory called eclipse with a program eclipse.exe.

  3. We will be using Subversion to commit code to the instructional servers. Subversive is the plugin for Eclipse that supports using Subversion in it. It does not come with the Eclipse package, so we have to install it manually.

    Start Eclipse by running eclipse.exe. It will ask you a location to the workspace. You may choose C:\CS61B\workspace for now. From the main menu, choose "Help" → "Software Updates". In the popup dialog, choose the "Available Software" tab and click "Add Site" to add the following sites one by one:

    http://download.eclipse.org/technology/subversive/0.7/update-site/
    http://www.polarion.org/projects/subversive/download/eclipse/2.0/update-site/
    http://www.polarion.org/projects/subversive/download/eclipse/2.0/ganymede-site/
    (Refer to this webpage for up-to-date information about Eclipse update sites.)

    After that, expand the node with the second URL as its name, and check "Subversive SVN Connectors". Click "Install..." and follow the steps thereafter. Eclipse will automatically figure out other packages that need to be installed as dependencies of "Subversive SVN Connectors", and install all of them. Restart Eclipse when prompted and our programming environment is ready.

    For those who are not able to access the Eclipse update site, follow these steps to perform a manual Subversive installation:plugins directory of your Eclipse installation:

    1. Download Subversive-incubation-0.7.1.I20080612-1500.zip from the Eclipse download site.

    2. Extract all the .jar files in the plugins path of the zip file to the plugins directory of your Eclipse installation.

    3. Download org.polarion.eclipse.team.svn.connector.svnkit15_2.0.1.I20080612-1500.jar and place it in the plugins directory of your Eclipse installation.

    (This manual installation instruction is not supposed to work all the time and it may break your Eclipse installation.)

Once the programming environment is ready, we can create a project and write some code. But before we do that, we have to set up Subversion so that we can check our code into the instructional servers:

  1. In Eclipse, choose "Window" → "Open Perspective" → "Other...". In the dialog, choose "SVN Repository Exploring".

  2. Choose "File" → "New" → "Repository Location" from the menu, and enter your account information.

  3. In the "New Repository Location" dialog, fill in the following URL in the "General" tab:

    https://isvn.eecs.berkeley.edu/cs61b/<YOURLOGIN>

  4. In the "Authentication" group, use <YOURLOGIN> as the user name, and enter your instructional password in the "Password" field.

  5. When you click the "Finish" button, you will see the new repository listed in the "SVN Repositories" window.

  6. Expand the repository and you will see a "trunk" node, a "tags" node, and more. Right click on "trunk" and choose "Find/Check Out As...". Click "Finish" in the new dialog, and choose "Java Project" under "Java" in the next dialog. You need to give your project a name. Let's call it cs61b. In the same dialog as you enter the project name, choose "Use project folder as root for sources and class files" so that Eclipse does not separate the source and the compiled binary code into different subdirectories of the project.

  7. When you click "Finish" and return to the Java prespective, you will see and your cs61b project.

We can now write a HelloWorld program and commit it to the server.

  1. Right click on the cs61b project and choose "New" → "Class". In the new dialog, enter "HelloWorld" in the "Name" field and check "public static void main(String[] args)". The following is generated in HelloWorld.java as the skeleton:

    public class HelloWorld {
      /**
       * @param args
       */
      public static void main(String[] args) {
        // TODO Auto-generated method stub
      }
    }

  2. Replace the contents of the main method (between the open and close brackets) with:

    System.out.println("Hello World!");

    Save the file. Eclipse will automatically compile the code in the background as long as "Project" → "Build Automatically" is checked.

  3. Click the run button from the tool bar (the one with a white triangle in a green circle), or choose "Run" → "Run", or press Ctrl+F11, to run the code. You will see "Hello World!" to be printed to the console at the bottom of the Eclipse window.

  4. To commit the code to the server, expand "cs61b" and "(default package)" in "Package Explorer" so that you can see "HelloWorld.java". Right click "HelloWorld.java" and choose "Team" → "Add to Version Control...". Click "OK" in the new Dialog.

  5. Right click the "cs61b" project and choose "Team" → "Commit...". In the new dialog, enter a short comment (say, "My first program."). In the same dialog, the resources updated locally are listed, such as "HelloWorld.java", ".classpath" and ".project". Press "OK" to commit all those files.

We've now committed the HelloWorld program into the SVN repository located on the instructional servers. You will be able to check out the code on any of the machines that you work on.

IMPORTANT: Make sure you commit your code regularly. There is no harm committing your code often, even though it is not executable yet or it contains bugs.


[CS61B Home Page]

Page was last modified on Mon Oct 3 15:16:50 2011.
Address comments and questions to cs61b@inst.eecs.berkeley.edu