How to call a stand alone java application from ADF BC JSP, struts or JSF

Hi,
My requirement is that there are utilities or stand alone java applications that I want to call from our existing applications.
We have two seperate applications one ADF BC Struts application we developed using JDeveloper 10.1.2 and another ADF BC JSF application we developed using JDeveloper 10.1.3.2.
We want to integrate applications like JTwain and others to help us in scanning. The application will be placed on the same server as our application. How can I do this without loosing all the current session information.
Please help.
Thanks and regards,

There are two possible solutions.
First, if the tool or application you want to integrate, has an Java-API you can use this api and integrate the tool in your application (using one or more jars you add to the classpath).
Second, if the tool has no java api, you can call the tool via runtime.exec(...) as a shell process. This way you open a command shell in you application and execute the tool like you do on a normal command shell.
For tide integration and control I recommend the first approach. The second one is only for those tools which don't offer a java api.
Timo

Similar Messages

  • How to call stand Alone java program from jsp

    Hello all...
    I want to use the stand alone java program in jsp page. I compiled the java program and place the class file in classes folder under web-inf. But when i try to instantiate the java class inside jsp it is not recognizing the class. Where might be the problem
    Plz help....
    Shamim

    hi , this is dheeraj.. i need to know that how to execute java code and class in jsp.. if anyone know about if bt tell me.. i just know that we can use java code by java beans in jsp.. if you know any knowledge regarding this topic please send me.....

  • How do I start and suspend Java Application from say C++ program

    I want to start a Java application via C++ and on some condition i want to suspend the same program not terminate , but suspend

    Have you tried running the virtual machine from your C++ application ? You can start Java applications from your C++ application using JNI after starting the Virtual machine from within your C++ application. According to the Java documentation you can even now stop the virtual machine from within your C++ program.
    I haven't looked at the 'suspend' detail but I suppose it will not be a problem to call a method via JNI to set a flag to suspend a thread etc.
    There is a tutorial: 'Invoking the Java Virtual Machine' at the following URL: http://java.sun.com/docs/books/tutorial/native1.1/invoking/invo.html.
    This example seems to work only for version1.1 of the JDK. For JDK1.3, version 1.2, (I am not so sure whether I fully understand Sun's version numbers for Java yet) there is some updates on the JNI for starting the VM from C++. This article is called 'JNI Enhancements'. The URL for this article is:
    http://java.sun.com/j2se/1.3.0/docs/guide/jni/jni-12.html
    You have to set version to: JNI_VERSION_1_2
    There is only one problem. I get an error when calling JNI_CreateJavaVM from C++. I could not find any documentation that indicates how you can go about diagnosing what is causing the problem. Normally in Visual C++ you can just get the probable cause by inspecting GetLastError() or the function itself can return helpful diagnostic (error) codes.
    If you manage to start the VM correctly from within Visual C++ please let me know. My email address is [email protected]
    good luck
    Henko

  • Consuming dataservice as a stand alone java client, givng an exception com

    when i am trying to access data service from a stand alone java application ,it giving an exception .
    The dataservice is in remote machine.
    Exception:
    com.bea.dsp.dsmediator.client.exception.SDOMediatorException: weblogic.rjvm.PeerGoneException: ; nested exception is:
         java.io.EOFException
         at com.bea.dsp.dsmediator.client.XmlDataServiceBase.invokeFunction(XmlDataServiceBase.java:322)
         at empldetappdataservices.EmployeeDetails.getEmployeesByid(EmployeeDetails.java:84)
         at com.patni.tsg.poc.DataServiceClient.DataServiceClient.main(DataServiceClient.java:42)
    Caused by: weblogic.rjvm.PeerGoneException: ; nested exception is:
         java.io.EOFException
         at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:108)
         at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:290)
         at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:248)
         at com.bea.ld.Server_ydm4ie_EOImpl_815_WLStub.executeFunction(Unknown Source)
         at com.bea.dsp.dsmediator.client.XmlDataServiceBase.invokeFunction(XmlDataServiceBase.java:312)
         ... 2 more
    Caused by: java.io.EOFException
         at weblogic.rjvm.t3.T3JVMConnection.endOfStream(T3JVMConnection.java:897)
         at weblogic.socket.SocketMuxer.deliverExceptionAndCleanup(SocketMuxer.java:586)
         at weblogic.socket.SocketMuxer.deliverEndOfStream(SocketMuxer.java:536)
         at weblogic.socket.SocketMuxer.readReadySocketOnce(SocketMuxer.java:694)
         at weblogic.socket.SocketMuxer.readReadySocket(SocketMuxer.java:641)
         at weblogic.socket.JavaSocketMuxer.processSockets(JavaSocketMuxer.java:282)
         at weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:32)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
    my class path i added all neccessary jars:
    weblogic.jar,xbean.jar,DataServices.jar,ld-server-core.jar,ld-client.jar,wlsdo.jar
    code sample:
    public static InitialContext getInitialContext() throws NamingException {
    Environment env = new Environment();
    env.setProviderUrl("t3://pc-p40892:7001");
    env.setInitialContextFactory("weblogic.jndi.WLInitialContextFactory");
    env.setSecurityPrincipal("weblogic");
    env.setSecurityCredentials("weblogic");
    return new InitialContext(env.getInitialContext().getEnvironment());
    public static void main (String args[]) {
    try {
    EmployeeDetailsDocument.EmployeeDetails edet=null;
    EmployeeDetails ds=EmployeeDetails.getInstance(getInitialContext(),"EmplDetApp");
    //The below statement generating the exception.
    EmployeeDetailsDocument[]doc =ds.getEmployeesByid("1001");
    } catch (Exception e) {
    e.printStackTrace();
    pls help me to solve this problem
    Edited by sandeepc221 at 09/19/2007 2:50 AM

    You didn't post the stack trace from the server, but I'm guessing it's complaining about the QName class. Sun changed the QName class in JDK 1.5 wreaking havoc on JDK 1.5 clients that use JDK 1.4 servers and attempt to pass a QName object from one to the other. If your client uses JDK 1.5, your sever will need to use a QName class which is compatible. The file liquiddata/lib/wls90interop.jar contains a QName class that is compatible with the one in JDK1.5. You can put it first in the classpath of your server.
    If you already have wls90interop.jar first in the classpath of your server, then, for your client, you need to either (1) use the Sun JDK 1.5; or (2) put wls90interop.jar first in the classpath of your client (if you are running JDK 1.4).
    http://e-docs.bea.com/aldsp/docs25/appdev/ejbclt.html#wp1090900
    btw - BEA Customer Support is available 24/7 - they should be able to provide you quick answers to questions like this.

  • Error when running "Run as" Java application from NWDS

    Dear All,
    I am trying to run the following .java proggie...
    Thanks for that. By the way, I am now trying to compile the following .java program.....
    Created on 01-Oct-2007
    To change the template for this generated file go to
    Window>Preferences>Java>Code Generation>Code and Comments
    @author chris.jackson
    To change the template for this generated type comment go to
    Window>Preferences>Java>Code Generation>Code and Comments
    import com.sap.lcr.api.cimclient.CIMClient;
    import com.sap.lcr.api.cimclient.CIMClientHandle;
    import com.sap.lcr.api.cimclient.CIMOMClient;
    import com.sap.lcr.api.cimclient.ClientFactory;
    import com.sap.lcr.api.sapmodel.SAP_AppServJCODestination;
    import com.sap.lcr.api.sapmodel.SAP_JCODestination;
    import com.sap.lcr.api.sapmodel.SAP_JCODestinationAccessor;
    import com.sap.lcr.api.sapmodel.SAP_MsgServJCODestination;
    import com.sap.mw.jco.JCO;
    import com.tssap.dtr.client.lib.protocol.URL;
    public class sldpoke {
    public void main() {
    ClientFactory factory = ClientFactory.newInstance();
    try {
    final URL url = new URL("http://ex1d002a.eu.unilever.com:58300/sld/cimom");
    String sldUsername = "cjacks01";
    String sldPassword = "password";
    CIMOMClient cimomClient = factory.createClient (url, sldUsername, sldPassword);
    CIMClient cc = new CIMClient(cimomClient);
    CIMClientHandle cch = (CIMClientHandle) cc;
    SAP_JCODestinationAccessor jcoAccessor = new SAP_JCODestinationAccessor(cc);
    SAP_JCODestination[] jcoDestinations = jcoAccessor.enumerateSAP_JCODestinationInstances();
    JCO.Client jcoClient = null;
    String user = null;
    String pwd = null;
    // iterate over all destinations
    for (int i = 0; i < jcoDestinations.length; i++)
    SAP_JCODestination jcoDestination = jcoDestinations;
    user = jcoDestination.getLogonUser();
    pwd = jcoDestination.getLogonPwd();
    if (jcoDestination instanceof SAP_AppServJCODestination)
    SAP_AppServJCODestination jcoDest = (SAP_AppServJCODestination) jcoDestination;
    jcoClient = JCO.createClient(jcoDest.getLogonBCClient(),
    user,
    pwd,
    jcoDest.getLogonLanguage(),
    jcoDest.getAppServHost(),
    jcoDest.getAppServNumber());
    else if (jcoDestination instanceof SAP_MsgServJCODestination)
    SAP_MsgServJCODestination jcoDest = (SAP_MsgServJCODestination) jcoDestination;
    jcoClient = JCO.createClient(jcoDest.getLogonBCClient(),
    user,
    pwd,
    jcoDest.getLogonLanguage(),
    jcoDest.getMsgServHost(),
    jcoDest.getSAPSystemName(),
    jcoDest.getLogonGroup());
    } catch (Exception e) {
    and I am getting the message "The selection does not contain a main type". The class contains a 'main' function so I am at a loss as to what the problem is. Any ideas how I progress?
    Kind Regards
    Chris Jackson.

    Hi! Jakson,
       to run a Stand-alone Java application, we must have one main() method like...
    public static void main(String args[]){ }
    i can't see this main() method on your appliation.
    regards,
    Mithileshwar

  • Calling a web service through SSL via a stand alone java class

    HI,
    I am trying to call a web service through SSL via a simple stand alone java client.
    I have imported the SSL certificate in my keystore by using the keytool -import command.
    Basically I want to add a user to a group on the server. Say I add a user user 1 to group group 1 using an admin userid and password. All these values are set in an xml file which I send to the server while calling the server. I pass the web service URL, the soap action name and the xml to post as the command line arguments to the java client.
    My xml file(Add.xml) that is posted looks like :
    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope
    xmlns:xsi = "http://www.w3.org/1999/XMLSchema-instance"
    xmlns:SOAP-ENC = "http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:SOAP-ENV = "http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd = "http://www.w3.org/1999/XMLSchema"
    SOAP-ENV:encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/">
    <SOAP-ENV:Body>
    <namesp1:modifyGroupOperation xmlns:namesp1 = "/services/modifyGroup/modifyGroupOp">
    <auth>
    <user>adminUser</user>
    <password>adminPassword</password>
    </auth>
    <operationType>ADD</operationType>
    <groupName>group1</groupName>
    <users>
    <userName>user1</userName>
    </users>
    </namesp1:modifyGroupOperation>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    I call the client as:
    java PostXML https://com.webservice.com/services/modifyGroup "/services/modifyGroup/modifyGroupOp" Add.xml
    I my client, I have set the following:
    System.setProperty("javax.net.ssl.keyStore", "C:\\Program Files\\Java\\jre1.5.0_12\\lib\\security\\cacerts");
    System.setProperty("javax.net.ssl.keyStorePassword", "password");
    System.setProperty("javax.net.ssl.trustStore", "C:\\Program Files\\Java\\jre1.5.0_12\\lib\\security\\cacerts");
    System.setProperty("javax.net.ssl.trustStorePassword", "password");
    But when I try to execute the java client, I get the following error:
    setting up default SSLSocketFactory
    use default SunJSSE impl class: com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl
    class com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl is loaded
    keyStore is : C:\Program Files\Java\jre1.5.0_12\lib\security\cacerts
    keyStore type is : jks
    keyStore provider is :
    init keystore
    init keymanager of type SunX509
    trustStore is: C:\Program Files\Java\jre1.5.0_12\lib\security\cacerts
    trustStore type is : jks
    trustStore provider is :
    init truststore
    adding as trusted cert:
    init context
    trigger seeding of SecureRandom
    done seeding SecureRandom
    instantiated an instance of class com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl
    main, setSoTimeout(0) called
    main, setSoTimeout(0) called
    %% No cached client session
    *** ClientHello, TLSv1
    RandomCookie: GMT: .....
    Compression Methods: { 0 }
    [write] MD5 and SHA1 hashes: len = 73
    main, WRITE: TLSv1 Handshake, length = 73
    [write] MD5 and SHA1 hashes: len = 98
    main, WRITE: SSLv2 client hello message, length = 98
    [Raw write]: length = 100
    [Raw read]: length = 5
    [Raw read]: length = 58
    main, READ: TLSv1 Handshake, length = 58
    *** ServerHello, TLSv1
    %% Created: [Session-1, SSL_RSA_WITH_RC4_128_MD5]
    ** SSL_RSA_WITH_RC4_128_MD5
    [read] MD5 and SHA1 hashes: len = 58
    [Raw read]: length = 5
    [Raw read]: length = 5530
    main, READ: TLSv1 Handshake, length = 5530
    *** Certificate chain
    chain [0] = ...
    chain [1] = ...
    chain [2] = ...
    chain [3] = ...
    main, SEND TLSv1 ALERT: fatal, description = certificate_unknown
    main, WRITE: TLSv1 Alert, length = 2
    [Raw write]: length = 7
    0000: 15 03 01 00 02 02 2E .......
    main, called closeSocket()
    main, handling exception: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    main, called close()
    main, called closeInternal(true)
    main, called close()
    main, called closeInternal(true)
    main, called close()
    main, called closeInternal(true)
    Exception in thread "main" javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.c
    ertpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(Unknown Source)
    at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Unknown Source)
    at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Unknown Source)
    at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(Unknown Source)
    at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(Unknown Source)
    at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Unknown Source)
    at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(Unknown Source)
    at com.sun.net.ssl.internal.ssl.AppOutputStream.write(Unknown Source)
    at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
    at java.io.BufferedOutputStream.flush(Unknown Source)
    at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:506)
    at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2110)
    at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1088)
    at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
    at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
    at PostXML.main(PostXML.java:111)
    Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find v
    alid certification path to requested target
    at sun.security.validator.PKIXValidator.doBuild(Unknown Source)
    at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
    at sun.security.validator.Validator.validate(Unknown Source)
    at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
    at com.sun.net.ssl.internal.ssl.JsseX509TrustManager.checkServerTrusted(Unknown Source)
    ... 18 more
    Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
    at java.security.cert.CertPathBuilder.build(Unknown Source)
    ... 23 more
    I do not know where I have gone wrong. Could someone point out my mistake.
    Thanks In advance!

    Hi jazz123,
    There's an example in the [*Java Web Services Tutorial*|http://java.sun.com/webservices/docs/2.0/tutorial/doc/] : see Chapter 1: Building Web Services with JAX-WS - A Simple JAX-WS Client.

  • Calling a web service from a stand alone java class

    I need to invoke a web service from stand alone java class- Please let me know how to acheive this.
    Thanks

    Hi jazz123,
    There's an example in the [*Java Web Services Tutorial*|http://java.sun.com/webservices/docs/2.0/tutorial/doc/] : see Chapter 1: Building Web Services with JAX-WS - A Simple JAX-WS Client.

  • How to call a WD JAVA application from a WD ABAP application

    Hi experts,
    Here I have two applications with me. One has been created through WebDynpro ABAP while the other one has been created through WebDynpro JAVA. Now i have to call upon the JAVA aplication from my ABAp application. In other words in need to integrate both the applications so as to have an easy navigation in between them.
    In the whole process I need to take care that the data is not lost from both ABAP or JAVA side.
    Please help me someone knows the solution.
    Regards,
    Kaustubh Maithani

    Hi,
    Usally to run WebDynpro for Java Application, we get the Application URL.
    If you want to call this WebDynpro Java Application from Webdynpro Abap, then create UI element like Link to Action or LinktoURL and give the url as WebDynpro for Java URL.
    Regards,
    Lakshmi Prasad.

  • Database connection pool to stand alone java class

    Hi all,
    I would like to know the best way to use a database connection pool with a stand alone java class.
    In my web applications I usually use JDBC Data Source version 5 to connect to my database. In this case, I connect to an Oracle database. But in this scene, I've a WebSphere Application Server to provide this connection pool. But for stand alone applications, I don't know how to do because I don't have a Application server to run on.
    Can enyone help me with this beginner question?
    Best regards.

    I tried to find the pool class I created but it must be on another CD. Anyway, you can easily create a number of connections and place them on a stack (your own or java's). When you need one, pop it off. When you are finished, push it back.
    Good luck.

  • Call a Java Application from MicroFocus COBOL (in UNIX environment)

    Hello,
    Could you please let me know, how to call a Java application from a MicroFocus COBOL application. If anyone has any code samples, that would be of great help.
    Thanks in advance,
    Tijo.

    You generally can't cause a program to be executed on a different >server. Basic security, you know. Besides this idea of having the Java >application run on a different server wasn't mentioned in your original >post. That leads me to believe we don't have the whole story.So I think you need to step back and find out what are the requirements. For example: Does your program need to start this Java application running, or is it already running and your program needs to connect to it somehow?
    My program has to start a Java class file, meaning that the Micro Focus COBOL module will call the Java class file. Will it be running on the same machine as your program, or on some other machine?
    For both cases, I would like to know the answer.a) Running on the same machine as my program is running.
    b) Running on the different machine.
    And then there are the questions about whether your program needs to have a conversation with the Java application, or whether it just needs to start it and that's all.
    COBOL program has to call a Java class by passing some parameters and Java class in turn process it and return some value back.. Kind of Request and Response model.Plenty of questions to be asked. Go and find out what they are.
    Sorry ... if I am not clear on my questions. Anyhow, thank you very much for providing the information.

  • Calling a Java Application from MicroFocus COBOL.... (in UNIX environment)

    Hello,
    Could you please let me know, how to call a Java application from a MicroFocus COBOL application. If anyone has any code samples, that would be of great help.
    Thanks in advance,
    Tijo.

    Annoyingly crossposted.
    http://forum.java.sun.com/thread.jspa?threadID=730657

  • Calling Java application from servlet

    Hi !
    I'm trying to run a Java application from within a servlet with Tomcat 4. I'm using the Runtime.getRuntime ().exec () method. So the application is run in a different JVM as a subprocess of the servlet. I use ObjectInputStream and ObjectOutputStream and a serializable object to enable communication between the servlet and the application.
    I tested the application and the serializable object with another Java application that works as the caller and it works fine. However, replacing the caller application with the servlet I get a StreamCorruptedException. The structure of the caller application and the servlet is the same.
    My questions are:
    - Is there something I should configure in Tomcat to create a subprocess ?
    - What is the cause of the StreamCorruptedException ? How do I get it with the servlet and not with the application ?
    - Should I use an environment with the call to Runtime.getRuntime ().exec () ? How do I use it ?
    - Is the called application forced to run in my servlet's context ?
    - Is there a better way to do this ?
    Thanks to all

    Here's my code:
    1. The serializable object:
    // Object Obj
    import java.io.*;
    public class Obj implements Serializable
    public int n;
    public Obj ()
    n = 0;
    public Obj (int n)
    this.n = n;
    public String toString ()
    return getClass ().getName () + " -> (n = " + n + ")";
    2. The application Sub (subprogram)
    // Application Sub
    import java.io.*;
    public class Sub
    private static File f;
    private static FileWriter fw;
    public static void main (String [] args)
    throws IOException, InterruptedException, ClassNotFoundException
    ObjectInputStream ois;
    ObjectOutputStream oos;
    Obj obj;
    ois = new ObjectInputStream (System.in);
    obj = (Obj) ois.readObject ();
    f = new File ("Sub.txt");
    fw = new FileWriter (f);
    fw.write (obj.toString ());
    fw.close ();
    oos = new ObjectOutputStream (System.out);
    oos.writeObject (obj);
    ois.close ();
    oos.close ();
    3. The application AMain (caller application)
    // Application AMain
    import java.io.*;
    class AMain
    private static File f;
    private static FileWriter fw;
    public static void main (String [] args)
    throws IOException, ClassNotFoundException
    Runtime r;
    Process p;
    ObjectInputStream ois;
    ObjectOutputStream oos;
    Obj obj, obj2;
    r = Runtime.getRuntime ();
    p = r.exec ("java Sub");
    oos = new ObjectOutputStream (p.getOutputStream ());
    obj = new Obj (5);
    oos.writeObject (obj);
    oos.flush ();
    B.comunica (obj);
    System.out.println ("AMain sends to Sub: " + obj.toString ());
    try
    p.waitFor ();
    catch (InterruptedException e)
    System.out.println ("Subprogram was interrupted");
    System.out.println (e.toString ());
    ois = new ObjectInputStream (p.getInputStream ());
    System.out.print ("Sub sends to AMain: ");
    obj2 = (Obj) ois.readObject ();
    System.out.println (" " + obj2.toString ());
    oos.close ();
    ois.close ();
    p.destroy ();
    4. The servlet SMain (the calling servlet)
    // Servlet SMain
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.io.*;
    import java.util.*;
    public class SMain extends HttpServlet
    public void doPost (HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
    Runtime r;
    Process p;
    ObjectInputStream ois;
    ObjectOutputStream oos;
    Obj obj, obj2;
    int state, i;
    res.setContentType ("text/html");
    ServletOutputStream out = res.getOutputStream ();
    out.println ("<html>");
    out.println ("<head><title>Sub</title></head>");
    out.println ("<body>");
    out.println ("Invoking subprogram...");
    out.println ("<br>");
    try
    r = Runtime.getRuntime();
    p = r.exec ("java -cp .;c:\\Programs\\Apache~1.0\\webapps\\SMain\\WEB-INF\\classes Sub");
    out.println ("...invoked<br>");
    oos = new ObjectOutputStream (p.getOutputStream ());
    obj = new Obj (5);
    oos.writeObject (obj);
    oos.flush ();
    out.println ("<br>SMain sends to Sub: " + obj.toString () + "<br>");
    try
    p.waitFor ();
    catch (InterruptedException e)
    out.println ("<br>Subprogram was interrupted<br>");
    out.println ("<br>" + e.toString () + "<br>");
    state = p.exitValue ();
    out.println ("<br>Subprogram state: " + state + "<br>");
    ois = new ObjectInputStream (p.getInputStream ());
    out.print ("<br>Sub sends to SMain: ");
    obj2 = (Obj) ois.readObject ();
    p.destroy ();
    catch (SecurityException e)
    out.println ("<br>SecurityException<br>");
    out.println ("<br>" + e.toString () + "<br>");
    catch (IOException e)
    out.println ("<br>IOException<br>");
    out.println ("<br>" + e.toString () + "<br>");
    catch (Exception e)
    out.println ("<br>Exception<br>");
    out.println ("<br>" + e.toString () + "<br>");
    out.println ("</body>");
    out.println ("</html>");
    So, as you can see, both application AMain and servlet SMain invoke application Sub and pass it the serializable object Obj. Oddly enough, application AMain works fine whereas servlet SMain throws a StreamCorruptedException exception.
    johnpoole said:
    �It's hard to guess what would cause the exception without seeing code, but the interaction between the processes would differ from that between two applications, because the servlet process is started with a different class loader. I'm not sure which one the jvm started by the call would use.�
    How can I enforce that a System classloader be used in the call to Runtime.getRuntime ().exec () ? (I mean by System classloader a classloader equals to the one applications are launched from console).
    johnpoole said
    �Is there a reason why you aren't starting the second process manually and then connecting to it on a port?�
    The idea is providing a Web interface for an application running in the server. The servlet is used to restrict access to this application but once access is granted (passing the servlet) the application should not be constrained.

  • Calling Java Application from another

    How can i call a Java Application from another java App.
    eg., If my Java application is called MyApp and i would like call another java application from within it.
    One way could be by using "System". I would like to know if there is any other method and is portable.
    Thanks in advance.

    hi,
    it works and not!
    if you start an other class with a command like this the 2nd prog/class terminates too if you terminate the caller-class!
    dear
    oliver scorp

  • How to Call third party Jar into Application

    Hi Can any Expert help ?
    I want to put third party Jar into my application but i have some problem occur.
    1. how to call jar with parameter in application ?
    2. when i exit the third party jar task, it will exit my main task too. How to set my main tast exit stats standalone ?
    3. I have over 10 jar files in one application, how can i set a classpath for client to call JNLP, instread of load all jar to client before run.
    Thanks.
    Sanki Poon ([email protected])

    1) Sounds like you are trying to launch the third party from it's application main instead of using it as an API How does your code interact with it or is that not important?. You don't call a jar, you load a class. You could use a exec http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Runtime.html to run the java launcher and pass it all it's command line stuff(But this may not be possible security wise via WebStart).
    2) if it is launched in the same JVM and it calls a System.exit there is nothing you can do about your app closing too. It would need to be in another instance of the JVM
    3) Under the resources tag you can have as many jar tags as needed.
        <resources>
            <j2se version="1.5.0" java-vm-args="-esa -Xnoclassgc"/>
            <jar href="/jsf-wita/apps/MathMLWebEditor.jar"/>
        </resources>

  • How to invoke java application from ABAP

    How to invoke java application from ABAP  ? Suppose I needto execute a EJB wihic is running on my SAP J2EE Enigne from an ABAP Program .
    Thanks,
    Manish

    Hi Manish,
    did you get some further documents concerning "abap program calls ejb"?
    If yes, could you please send me some informations.
    Thank you for your help.
    Kind regards, Patrick.

Maybe you are looking for

  • Main VI is not updating the data from subVI

    Dear all, I have a Vi A using the data front a subVi B. When I run it, I see the data is updating in the subVI, but not the main Vi and the Front Panel. The subVi has three output channels and the main Vi tries to display those three channel data on

  • Mac mini screen res changes through gcs634u

    I have a mac mini and use it via a 2port Iogear kvm to a HP2408 @1920x1200 resolution. I just bought a new 4port Iogear 634u but when i connect the mac it changes the resolution to 1280x1024 and does not give me the option to do 1920x1200 at all. If

  • How can i get my sound to work?

    When I get a phone call or message or talk to someone, I cant hear anything. Also none of the sound in my Apps work, but when I put someone on loud speaker i can hear them?

  • A bug in user profile modification(?)

    All, Not sure if this is a problem w/my install of Portal(3.0.7.6) or is this a generic prob. 1.Login as Portal30 (or whoever is the Portal owner) 2.Create a user, say,JDOE and save the user. 3.From Portal Navigator->Edit User->JDOE 4.Goto the Prefer

  • Web Dynpro ABAP Unwanted Menu Bar

    Goodday, I'm calling a custom transaction in the back end from my WD App by using CALL METHOD lo_window_manager->create_external_window I have 'sentenced' all the 'bars parameters ' to abap_false. In the back end a custom transaction gathers all info