How to add EAR files in a java console application
I want to know how to add an EAR开发者_开发问答 file into a simple java class i.e a standalone application.
Let say i have a class Employee
package com.Employee;
import com.xyz.Workflow;//this library is present in EAR file whose method i need to call
public class Employee{
public static void main(String[] args)
// Workflow wf = new Workflow();
// ws.initiateWorkflow(); // this method needs to be called but for that i need to include this EAR which is given to me from a 3rd party;
}
Can any one help me the API is in EAR only.
EAR files are for use within a JavaEE application server, not a standalone application.
You'll need to unpack the EAR (it's just a JAR file with a different file extensions, so use an unzip tool or the jar
command line utility), and then point your console application's classpath at the contents of the EAR. You'll to look through the structure to see where the bits you need are located.
Typically when you create an ear, there is a core pare running the EJB's or similar service layer for which the methods which make sense to be made available are exposed using RMI, SOAP or other remote procedure call method. There usually exists a "client" library which contains the interfaces and glue logic to call the public services of the EAR application.
There is little chance that calling methods directly from the jars inside the ear on a client will have the desired effect.
精彩评论