The Java EE 6 Tutorial, Volume I

Compiling, Packaging, and Running the converter Example

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

Compiling, Packaging, and Running the converter Example in NetBeans IDE

    Follow these instructions to build and package 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 Run. A web browser window will open the URL http://localhost:8080/converter

Compiling, Packaging, and Running the converter Example Using Ant

    To compile and package converter using Ant, do the following:

  1. In a terminal window, go to this directory:


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


    ant all
    
  3. Open a web browser to the following URL:


    http://localhost:8080/converter

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 preceding ant task includes the Java EE API JAR files in the classpath. These JARs reside in the modules directory of your Enterprise 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.


After entering 100 in the input field and clicking Submit, you should see the screen shown in Figure 15–1.

Figure 15–1 converter Web Client

Screenshot showing the converter web client.