Java™ EE application
clients are similar to regular Java applications.
Both contain a main() method that runs
and continues running until the client virtual machine stops. Both
can run as typical "fat client" applications in order to display a
GUI that connects to a set of EJB beans for persistence and business
logic, or as server applications that provide services over the network.
However, a Java EE application
client has several advantages over regular Java applications because it runs within a lightweight
server container. This container can provide the application client
with services that were previously available only to other Java EE components.
Before you begin
- Create an EAR that contains a complete application client project.
About this task
Using Java EE application
clients instead of regular Java applications
has the following advantages:
- Ability to run inside a server container, providing richer APIs.
- Use of Java EE security,
including authentication and server-specific functions that might
include features such as single-sign-on.
- Guaranteed Java Platform,
Enterprise Edition platform APIs available, and container extensions.
- Simple JNDI lookup: initial context properties are picked up from
the container.
- Packaged like other Java EE
components, providing portability, easy deployment, and clean packaging.
A deployer can modify the deployment information in order to move
to a different server without changing code.
- Use of the java:comp namespace to
indirectly reference EJB beans.
To build a full command line to start an application client,
complete the following steps:
Procedure
- Switch to the Debug perspective ().
- In the main toolbar, expand the Run icon
and select Run Configurations, alternatively
expand the Debug icon
and select Debug Configurations.
- Select WebSphere Application Server vx.x Application
Client, where x.x is the version level
of the WebSphere® Application
Server and click New launch configuration.
- In the Name field, enter the name
of your configuration.
- In the Application tab, select your enterprise application
from the Enterprise Application list.
- In the Arguments tab, you can add Program arguments, VM
arguments and specify your working directory. All WebSphere Application Server
client launcher arguments begin with -CC.
The default Program argument is -CCverbose=true,
which provides useful debugging information and at run time. Any arguments
that do not start with -cc pass to your
application at run time. For details on the various Program arguments
and VM arguments, see the launchClient tool topic available in the Information
Center for WebSphere Application
Server.
- Package everything
that is required by your application into your EAR file. However,
if you want to reference classes that are not in the EAR file, use
the -CCclasspath parameter. For details on the -CCclasspath parameter,
see the Java EE client
application class loading topic available in the Information
Center for WebSphere Application
Server.
Tip: The Classpath tab available in
the launch configuration has lead to common usage errors, such as ClassNotFoundException.
This Classpath tab is reserved for adding references for the launch
configuration. Do not use the Classpath tab for referencing classes
particular to running your application. Instead, specify your application
references with the -CCclasspath parameter in the
Arguments tab.
- After configuring your launch configurations, click Apply to
set your configuration, then click Run to start
the application client.