Java EE 7 SDK

# Common Build Instructions for Sample Applications

The sample applications depend on the following software:

- Java SE Development Kit (JDK) version 1.7.0_21.
- Apache Maven version 3.0.5.
- The Java DB database included in the Java EE SDK.

Due to these dependencies, you must perform some one-time setup tasks before building and running the individual samples.

### One-Time Setup Tasks

Note: In the following instructions, `<javee.home>` refers to the directory where the Java EE SDK is installed; for example, `C:\glassfish4`.

1. Download and install JDK version 1.7.0_21, if necessary. If JDK version 1.7.0_21 is not already on your system, you must download and install it. The download is available at the Java SE Downloads page.
2. Download and install Apache Maven version 3.0.5, if necessary. If Apache Maven version 3.0.5 is not already installed on your system, the download is available at the Maven download page.

Refer to the Maven documentation page for information on configuring and using Maven. For example, you may have to specify a proxy server if your network environment requires it.

### Building and Running a Sample Application

After performing the one-time setup tasks, you can build and run a sample application as follows:

1. Add the JDK 1.7.0_21 `bin` directory to your `PATH` environment variable. For example:

   `set PATH=C:\Program Files\Java\jdk1.7.0_21\bin;%PATH%`

2. Add the Maven 3.0.5 `bin` directory to your `PATH` environment variable. For example:

   `set PATH=C:\Program Files\apache-maven-3.0.5\bin;%PATH%`

3. Follow the instructions for the specific sample to build and run it. Note that many of the samples use the following common Maven goals:

   - `compile` - compiles the sample application.
   - `install` - packages the archive and installs it in the local Maven repository.
   - `verify` - verifies that the package is valid.
   - `cargo:run -Dglassfish.home=<gf_install_dir>` - runs the application using the application server in the SDK.
   - `clean` - deletes the compilation artifacts.

To specify the installation directory of the Glassfish server, use the `-Dglassfish.home=<gf_install_dir>` option with the `cargo:run` goal.

### Sample Applications as NetBeans Projects

You can open the sample applications as projects in the NetBeans IDE. To do so, follow these steps after downloading and installing NetBeans from the NetBeans Download page:

1. Set JDK 1.7.0 as the default Java platform by changing the `netbeans_jdkhome` property in the `<netbeans.home>\etc\netbeans.conf` file.
2. Configure the browser that the NetBeans IDE will use by selecting Tools->Options->General->WebBrowser.
3. Configure the GlassFish 4 server to use JDK 1.7.0 by selecting Tools->Servers and then clicking on the Java tab for the GlassFish 4 Domain.
4. Start the GlassFish server:

   1. Choose Windows->Services.
   2. Expand the Servers group.
   3. Right-click on the GlassFish domain and choose Start from the context menu.
5. Open one of the sample applications:

   1. Choose File->Open Project.
   2. Navigate to the `<javaee.home>\glassfish\samples\javaee7` directory and then to the appropriate sample project.
   3. Select the sample project.
   4. After NetBeans scans the project, select Open Required Projects if projects appear in the box below the option, and then click on Open Project.
6. Check the sample's `docs/index.html` file for any special prerequisites or build instructions.
7. Right-click on the sample project and execute one of the Maven targets; for example, Run.

Copyright © 1997-2013 Oracle and/or its affiliates. All rights reserved.