Creating your first Java project

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

  1. Open the New Project wizard by selecting the menu item File > New > Project....

  2. On the left pane of the first wizard page, select Java, and on the right pane, select Java Project. Then click Next.

    In the Project name field, type "JUnit", then click Finish. A new Java perspective opens within the workbench with the new Java project in the Package Explorer.

    Along with the new Java perspective, 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 <workbenchRoot>/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. Below the import hierarchy list in the Import wizard, click the Select All button.

    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.

  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