The Java EE 6 Tutorial

Building, Packaging, Deploying, and Running the converter Example

Now you are ready to compile the enterprise bean class (ConverterBean.java) and the servlet class (ConverterServlet.java) and to package the compiled classes into a WAR file.

ProcedureTo Build, Package, and Deploy the converter Example in NetBeans IDE

  1. In NetBeans IDE, select File->Open Project.

  2. In the Open Project dialog, navigate to:


    tut-install/examples/ejb/
    
  3. Select the converter folder.

  4. Select the Open as Main Project and Open Required Projects check boxes.

  5. Click Open Project.

  6. In the Projects tab, right-click the converter project and select Deploy.

    A web browser window opens the URL http://localhost:8080/converter.

ProcedureTo Build, Package, and Deploy the converter Example Using Ant

  1. In a terminal window, go to:


    tut-install/examples/ejb/converter/
  2. Type the following command:


    ant all
    

    This command calls the default task, which compiles the source files for the enterprise bean and the servlet, placing the class files in the build subdirectory (not the src directory) of the project. The default task packages the project into a WAR module: converter.war. For more information about the Ant tool, see Building the Examples.


    Note –

    When compiling the code, the ant task includes the Java EE API JAR files in the classpath. These JARs reside in the modules directory of your GlassFish Server installation. If you plan to use other tools to compile the source code for Java EE components, make sure that the classpath includes the Java EE API JAR files.


ProcedureTo Run the converter Example

  1. Open a web browser to the following URL:


    http://localhost:8080/converter

    The screen shown in Figure 15–1 appears.

    Figure 15–1 The converter Web Client

    Screen shot showing the converter web client.

  2. Type 100 in the input field and click Submit.

    A second page appears, showing the converted values.