Data Access Object (DAO), Java Pet Store Example and

Other Java Technologies 1

 

 

 

 

The NetBeans project environment setup includes:

  1. NetBeans 6.8 IDE

  2. JDK 1.6

  3. GlassFish v3 web server

  4. JavaDB/Derby database

  5. Java Pet Store Example in JAR

 

What do we have in this session?

  1. Download Java Pet Store Demo Project JAR File

  2. Uncompress the JAR File

  3. Opening the Project in NetBeans IDE

  4. Resolving Some Errors

  5. Removing and Re-installing Web Server in NetBeans

  6. Editing the New Web Server Path

  7. Changing Glassfish Web Server admin Password

  8. Starting JavaDB Database

  9. Starting the Glassfish Web Server

  10. Testing Glassfish Web Server

  11. Running Java Pet Store Application

  12. Java Pet Store in Action

 

 

 

 

In this short hands-on tutorial we will try to run Java Pet Store demo example in NetBeans 6.8 IDE. Java Pet Store demonstrates many Java technologies and in this tutorial we will see how the Data Access Object (DAO) was implemented.

 

Download Java Pet Store Demo Project JAR File

 

Firstly, download latest jar file for Java Pet Store demo project at: Java Pet Store Demo Project.

 

Java Pet Store Demo project download page

 

Uncompress the JAR File

 

Uncompress the jar file by double clicking the jar file or run the 'java -jar javapetstore-2.0-ea5-installer.jar' at the command line.

 

Java pet store JAR file

 

Accept the License Agreement. Click Accept.

 

Java Pet Store License Agreement

 

The following are the files and folders of Java Pet Store.

 

Uncompressed Java Pet Store files and folders

 

Optional step: Copy the javapetstore-2.0-ea5 folder to C:\ drive (if needed) to make the path is shorter when used in the NetBeans project file and if you put the demo example in the other folder, make sure the path doesn’t have white space(s). White space in the path name will make the project failed to be built/run later.

 

Java Pet Store project folder saved at C drive

 

 

 

 

Opening the Project in NetBeans IDE

 

Launch NetBeans (in this case version 6.8) IDE.

 

NetBeans 6.8 welcome flash screen

 

Open the Java pet store project in NetBeans. Click File menu > Open Project sub menu.

 

Opening existing Java project in NetBeans IDE

 

Select the Java pet store demo example project folder and click Open Project button.

 

Selecting the java pet store project folder

 

Resolving Some Errors

 

Optional step: If you encounter the "target server error" (with errors in the project/files as shown below), complete the following steps, else just skip them until the "Glassfish server setup" section.

 

Missing Server Problem for NetBeans IDE message

 

The "target server error" produces the following source code errors.

 

Missing Server Problem errors seen in the opened project in NetBeans

 

To resolve the "missing server problem", select the project folder in the Projects page > right click mouse > select Resolve Missing Server Problem menu.

 

 

 

 

------------------------------------------------------------

 

Resolving Missing Server Problem in NetBeans

 

Select Glassfish v3 web server (or your desired web server) and click OK.

 

Selecting GlassFish v3 Domain

 

Removing and Re-installing Web Server in NetBeans

 

Optional step: Next, we have to make sure the Glassfish installation folder (and path) also doesn’t have whitespace(s) else the project building will fail. If your GlassFish installation folder (path) having whitespace(s) then remove the server and re-install it. The steps are shown in the following section. If the installation folder doesn’t have whitespace(s) then you can skip the following steps until the "modify the Glassfish root folder" section.

Firstly, remove the existing Glassfish web server. From NetBeans IDE, select Services tab > under the Servers folder, expand it > select the server that will be removed > right click mouse > select Remove context menu.

 

Removing web server in NetBeans

 

Then, 're-install' the Glassfish v3 web server. In the Services page select Servers folder > right click mouse > select Add Server menu.

 

Adding new web server in NetBeans

 

From Add Server Instance page, select GlassFish v3 from Server: text box > click Next.

 

Selecting new GlassFish v3 web server

 

You need to create the sges-v3 folder manually (in this case at C: drive) and then point the Installation Location: to C:\sges-v3. Select the license agreement and click the Download Now button. This is an online installation/update.

 

 

 

 

Setting the Web server installation path. The name must be sges-v3 and can start downloading the files

 

Wait until the online installation complete.

 

The new web server installation begins

 

After the online installation finish, click the Next button.

 

The web server download and install was completed successfully

 

Select domain1 (default first domain) as the domain and click Finish button.

 

Selecting the domain for the GlassFish web server

 

 

 

 

 


 Back to Main | java Pet Store 2