Organizing sources

In this section, you will create a new Java project and organize your sources in separate folders. This will prepare you for handling more complex layouts.

Let's assume you want to put your sources in one folder and your tests in another folder:

Sources and tests folders

  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.
  3. On the next page, type "MyProject" in the Project name field and click Next.

    Java Project Name Setting

  4. Click Add Folder....
  5. On the next dialog, click Create New Folder...
  6. Type "sources" in the Folder name field.

    Java Project Name Setting

  7. Click OK twice to close the two dialogs.
  8. You will be prompted whether or not to remove the project as a source folder and update the build output folder to "MyProject/bin". The builder will write the generated .class files to the output folder. Click Yes.

    Resulting Java Project Wizard

  9. To create the "tests" folder, repeat steps 4 to 7.

    Resulting Java Project Wizard

  10. Click Finish
  11. You now have a Java project with a "sources" and a "tests" folders. You can start adding classes to these folders or you can copy them using drag and drop.

    Java perspective

Related concepts

Java projects
Java views

Related tasks

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

Related reference

New Java Project Wizard
Package Explorer View

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