Creating your first Java project

In this section, you will create a new Java project. You will be using JUnit as your example project. JUnit is an open source unit testing framework for Java. Refer to http://www.junit.org/ for more information on JUnit.

  1. Select the menu item File > New > Project.... to open the New Project wizard.
  2. On the left pane of the first wizard page, select Java, and on the right pane, select Java Project. Then click Next. On the next page, type "JUnit" in the Project name field and click Finish. A Java perspective opens inside the workbench with the new Java project in the Package Explorer. When the Java perspective is active, new menu options and Java specific buttons are loaded in the workbench toolbar. Depending on which view or editor is active, other buttons and menu options will be available.

    Java perspective

  3. In the Package Explorer, make sure that the JUnit project is selected. Select the menu item File > Import....
  4. Select Zip file, then click Next.
  5. Click the Browse button next to the Zip file field and browse to select <eclipseInstallPath>/plugins/org.eclipse.jdt.ui.examples.projects/archive/junit/junit37src.jar.
    Note: This step assumes that the JDT example plug-ins have been downloaded and installed.
  6. In the Import wizard, below the hierarchy list click Select All. You can expand and select elements within the junit directory on the left pane to view the individual resources that you are importing on the right pane. Note: Do not deselect any of the resources in the junit directory at this time. You will need all of these resources in the tutorial.

    Import hierarchy list

  7. Make sure that the JUnit project appears in the destination Folder field. Then click Finish. In the import progress indicator, notice that the imported resources are compiled as they are imported into the workbench. This is because the Perform build automatically on resource modification option is checked on the Workbench preferences page. You will be prompted to overwrite the .classpath file in the JUnit project. This is because the .classpath resource was created for you when you created the JUnit project. It is safe to overwrite this file.
  8. In the Package Explorer view, expand the JUnit project to view the JUnit packages.

    Package explorer

Related concepts

Java projects
Java views

Related tasks

Working with build paths
Creating a new Java project
Using the Package Explorer

Related reference

New Java Project Wizard
Package Explorer View

Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved.