Creating a new project


This quick start shows how to create a new Java Persistence Entity project. Before creating the project, you should open the new Persistence perspective.

  1. Switch to the new Persistence perspective to begin working with Java persistence entities. Select Window > Open Perspective > Other. The Select Perspective Dialog appears.

    Selecting Persistence Perspective

    The Window > Open Perspective > Other option.
  2. On the Select Perspective dialog, select Java Persistence and click OK. The workbench adds the Persistence Outline and Persistence Properties views.

    Select Perspective Dialog

    The Select Perspective dialog with the Perspective option.

Now, we will create a new Java project.

  1. Select File > New > Project. The New Project dialog appears.

  2. On the New Project dialog, select Java > Java Project and click Next. The Create a Java Project dialog appears.

  3. On the Create a Java Project dialog, enter a Project name (such as QuickStart) and click Next. The Java Settings page appears.


    Note:

    You must configure your project's JRE to use version 1.5 (or higher). See "Requirements and installation" for more information.

  4. On the Java Settings page click Finish. Eclipse adds the project to the workbench and opens the Java perspective.

Finally, we will "add persistence" to the project.

  1. Right-click the Java project in the Explorer and select Java Persistence > Add Java Persistence. The Add Java Persistence Dialog appears.

  2. On the Add Persistence dialog select a database connection (or click Add Connection to create a new connection).


    Note:

    You must be connected to the database before adding persistence to the project. You will also need to create a table named ADDRESS (you will add its columns later). Click Reconnect to reconnect to an existing database.

    Add Java Persistence Dialog

    The Add Java Persistence dialog.
  3. Click Configure the project build path to add the library or JARs that contain the Java Persistence API (JPA) and entities to the project's Java Build Path.

  4. In the Packaging Settings area, enter the necessary information for your persistence provider.

    Add Java Persistence Dialog

    The Add Java Persistence dialog.

    For information on using a persistence.xml file for packaging your project, see "Managing the persistence.xml file".

  5. Click Finish. Eclipse adds the persistence information to the project. You can now work in the Persistence perspective.

    Project in Package Explorer

    Package Explorer showing the Java persistent project.

Now that you have created a project with persistence, you can continue with Creating a Java persistent entity.