The
perspective is opened.Choose
from the main menu.Expand Java EE folder and choose Application Client Project. Choose Next.
Enter CalculatorServiceClient in the Project name field. This is the name of the Application Client Project.
Leave the Default Configuration for SAP Libraries in the Configurations field. The default configurations include the Application Client module 5.0 and Java 6.0 project facets.
To assign the Application Client Project to an Enterprise Application Project, choose Add project to an EAR and select CalculatorServiceEAR in the EAR Project Name field.
Choose Finish to create the Application Client Project.
Copy the Java source below.
Expand the project CalculatorServiceClient.
From the context menu of appClientModule folder, choose Paste.
Syntax
package com.sap.blogs.appclient.calculator.client; import com.sap.blogs.appclient.calculator.ejb.CalculatorRemote; import javax.ejb.EJB; public class CalculatorClient { @EJB private static CalculatorRemote calculator; /** * Creates a new instance of Starter */ public CalculatorClient() { } /** * @param args * the command line arguments */ public static void main(String[] args) { System.out.println("Welcome to calculator service!"); System.out.println(); System.out.print("Adding (4+6): "); long result = calculator.add(4, 6); System.out.println(result); } }
Note
A peculiarity of all Application Client applications is that they have to specify their main class in the archive's manifest file. Open META-INF/MANIFEST.MF and append:
Main-Class: com.sap.blogs.appclient.calculator.client.CalculatorClient
Since your Application Client project uses resources from the CalculatorServiceEJB project, you have to set these references:
Select CalculatorServiceClient in the Project Explorer.
From the context menu, choose Properties.
On the Properties for CalculatorServiceClient screen choose
.Choose Add.
Select CalculatorServiceEJB.
Choose OK.
Choose Project References.
On the Setting Java Build Path screen that pops up, choose Apply.
Select the CalculatorServiceEAR and CalculatorServiceEJB projects.
Choose OK.