Skip Headers
NetBeans Developing Applications with NetBeans IDE
Release 8.0

Go to Documentation Home
Go to Book List
Book List
Go to Table of Contents
Go to Feedback page
Contact Us

Go to previous page
Go to next page
PDF · Mobi · ePub

14 Developing Application Clients

This chapter describes how to create standalone applications for use in Java EE enterprise environments.

This chapter contains the following sections:

14.1 About Developing Application Clients

A Java EE application client is a stand-alone application that is configured to work as part of a Java EE enterprise application. Any Java application can access remote EJB methods and web services, so you do not necessarily have to create a Java EE application client to access your enterprise application. The advantage of accessing enterprise applications from enterprise application clients is that application clients have access to services and functionality running on the enterprise application server, while regular Java applications do not. For example, you can configure security roles and permissions for an enterprise application client.

14.2 Creating Application Clients

The following table summarizes the steps for creating an application client.

Table 14-1 Tasks for Creating Application Clients

Task Action

Create an application client.

  1. Choose File > New Project (Ctrl+Shift+N).

  2. Select the right template from the Enterprise Java Beans category. 

Build an application client.

Right-click the application client project node and choose Build.

Verify an application client.

Right-click the application client project node and choose Verify.

Run an application client.

  1. Start the application server.

  2. Deploy the enterprise application by right-clicking its project node and choosing Deploy.

  3. Right-click the application client project node and choose Run.

Generate a reference to an enterprise bean.

  1. Open any Java class file in the application client project.

  2. Right-click inside the class file and choose Insert Code > Call Enterprise Bean.

Edit an application client's deployment descriptors.

  1. Expand the Configuration Files node for the application client project.

  2. Double-click the deployment descriptor.

14.2.1 How to create an enterprise application client

Follow these steps to use the IDE to create an enterprise application client.

  1. Choose File > New Project (Ctrl+Shift+N). For more information, see Section 5.2.1, "Standard Project Templates."


    Before you can create an enterprise application project, you must register an application server.

  2. From the Java EE category, select one of the following project templates:

  3. Follow the steps in the rest of the wizard.


    If you want to turn a regular Java project into a Java EE application client, you have to add at least the application-client.xml deployment descriptor to the src/conf folder, then close the project and create it again using the Enterprise Application Client with Existing Sources template as described above.

For related information see Section 15.4, "Calling an Enterprise Bean."

14.2.2 How to edit the deployment descriptors of an enterprise application client

Deployment descriptors are XML-based text files whose elements describe how to assemble and deploy a module to a specific environment. The elements also contain behavioral information about components that is not included directly in code.

An application client generally has the following deployment descriptors:

  • application-client.xml. The general Java EE deployment descriptor that configures deployment settings on any Java EE compliant implementation.

  • The server-specific deployment descriptor that configures deployment settings for the application server to which you are deploying. For application clients deployed to the GlassFish Server, the file is named glassfish-application-client.xml. The IDE provides a graphical deployment descriptor editor for glassfish-application-client.xml and automatically updates the deployment descriptor as you edit your files. For other application servers, you have to write the server-specific deployment descriptors yourself.

The deployment descriptors for an application client are located in the project's src/conf folder. You can access the deployment descriptors from the project's Configuration Files node. For more information see Section 13.4.1, "How to Edit an Enterprise Application's Deployment Descriptors."

To edit application-client.xml:

  1. In the Projects window, expand the Configuration Files node for your application client project.

  2. Double-click application-client.xml to open it in the Source Editor. You have to edit the XML code by hand using the IDE's XML code completion and validation. There is no graphical editor for application-client.xml.

To edit glassfish-application-client.xml:

  1. Double-click glassfish-application-client.xml to open it in the graphical editor. The graphical editor opens in a Source Editor tab.

  2. Edit the deployment descriptor as necessary.

  3. Click XML to edit the XML source for glassfish-application-client.xml. The Source Editor provides code completion and validation for all XML files.

To edit the server-specific deployment descriptor for any other application server:

  • Double-click the deployment descriptor node. The IDE opens the XML source of the deployment descriptor in the Source Editor.


If you enter any XML syntax errors the IDE automatically alerts you. To fully ensure your changes have not caused any errors, you should verify the application client.

14.2.3 How to add a module to an enterprise application

EJB or web application modules can be deployed either by themselves or as a part of an enterprise application. Likewise, Java application clients can be either regular Java applications, or can be full Java EE application client modules. Adding an EJB module, web module, or application client module to an enterprise application lets you further configure the way those modules interact with each other.

When you add a module to an enterprise application, the IDE does the following:

  • Lists the module under the enterprise application's Java EE Modules node.

  • Adds the module project to the enterprise application project's list of required projects. This means that the module project is cleaned and built whenever you clean and build the enterprise application project.

  • Adds a module reference to the enterprise application's general deployment descriptors.

  • Packages the module's build output (JAR file or WAR file) into the enterprise application's EAR file when building the project.

To add an existing module to an enterprise application:

  1. Open the module project and the enterprise application project.

  2. In the Projects window, right-click the enterprise application node for the Java EE application and choose Add Java EE Module.

  3. In the dialog box, select the module and click OK.

    You can only add standard projects to an enterprise application. You cannot add free-form projects to an enterprise application because the build and deploy process is not controlled by the IDE.