background image

Packaging the converter Example

<< Coding the Enterprise Bean | Creating the converter Application Client >>
<< Coding the Enterprise Bean | Creating the converter Application Client >>

Packaging the converter Example

public BigDecimal yenToEuro(BigDecimal yen) {
BigDecimal result = yen.multiply(euroRate);
return result.setScale(2, BigDecimal.ROUND_UP);
}
}
Note the @Stateless annotation decorating the enterprise bean class. This lets the container
know that ConverterBean is a stateless session bean.
Compiling and Packaging the converter Example
Now you are ready to compile the remote business interface (Converter.java) and the
enterprise bean class (ConverterBean.java), and package the compiled classes into an
enterprise bean JAR.
Compiling and Packaging 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/javaeetutorial5/examples/ejb/.
3. Select the converter folder.
4. Select the Open as Main Project and Open Required Projects check boxes.
5. Click Open Project Folder.
6. In the Projects tab, right-click the converter project and select Build Project. You will see
the output in the Output tab.
Compiling and Packaging 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/javaeetutorial5/examples/ejb/converter/
2. Type the following command:
ant
This command calls the default task, which compiles the source files for the enterprise bean
and the application client, placing the class files in the build subdirectories (not the src
directory) of each submodule. Then the default task packages each submodule into the
appropriate package file: converter-app-client.jar for the application client,
Creating the Enterprise Bean
Chapter 21 · Getting Started with Enterprise Beans
647