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

Similar Messages

  • Web dynpro abap : Call an application from another with parameters

    Hi ,
    Could you please tell me how to call an application from another with parameters?
    Thanks a lot
    Karim

    * Construct the URL
          call method cl_wd_utilities=>construct_wd_url
            exporting
            application_name              = 'APPLICATIION_NAME'
          importing
            out_absolute_url              = g_url.
    * Append parameters to URL
      data: g_par1 = lv_value. " value of your parameter
      call method cl_http_server=>append_field_url
        exporting
          name  = 'PAR1' " Parameter name
          value = g_par1
        changing
          url   = g_url.
    * Call the Application
      DATA lo_window_manager TYPE REF TO if_wd_window_manager.
      DATA lo_api_component  TYPE REF TO if_wd_component.
      DATA lo_window         TYPE REF TO if_wd_window.
      lo_api_component  = wd_comp_controller->wd_get_api( ).
      lo_window_manager = lo_api_component->get_window_manager( ).
      lo_window         = lo_window_manager->create_external_window(
                       url = g_url ).
      lo_window->open( ).

  • How to call WD Application from another WD Appliction

    Hi all,
    how can we call webdynpro application from another wbdynpro application on click of a button in the same browser.
    pls suggest
    regards
    vishal

    Hi Vishal,
    Just try to Embed the another WD Component into Component Controller first.
    And then Create a View and map it to window as U regularly do,
    then in Window- Explore the tree until that View, now open Context Menu for Embed View Option and from the scroll U get search for that WD Component U wanna Embed.
    U also have to handle Plugs here, Because the result application required some parameters to be passed that U do from ur first application by passing  those values through Plugs.

  • Invoke one java application from another?

    Hello,
    Can anyone tell me how to Invoke one java application from another?
    Suppose I have a small java application say, Hello.java which has its own main() method and
    I also have another java application, say World.java which has its own main() method too.
    What I want to do is invoke or startup World.java from Hello.java.
    If possible kindly give code examples?

    main is just a normal method so Hello can invoke the main method of World just as it would invoke any other method.
    Kaj

  • 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 a java application from another

    Hello,
    i have noticed a strange behaviour of my java app when i open it from another java app. When i run the core application with a bat file using jre1.6 everything works fine. Now what i want to do is create an application that checks the existance of jre 1.6, downloads it if it does not exist and run real application with the new jre. The second small app runs with a small jre 1.4.2. In reality it seem to work fine, it downloads the jre1.6 folder and exits normally. However when the real application is launched it behaves strangely without throwing any exceptions. And this behaviour seems to be random. for example, a jpanel may not show any components, or the whole jframe may close suddenly. Does anyone have any idea what is going on? Is there a chance that some classes of the first jre remain in memory and conflict when the second application is launched?

    Just a wild guess: maybe you're invoking the java 1.6 binaries, but JAVA_HOME or something is pointing to java 1.4 libraries (or vice-versa), and you've found some weird interaction issue.

  • Launching a java application from another java application

    Hi,
    I'm facing an interesting challenge :-)
    Inside a Java application, I want to start another java application.
    Possible solutions in my list :
    1. Using jakarta commons launcher.
    2. Runtime.exec (make the code platform dependent).
    3. Starting the main method of the other app by create a new Thread inside the current app
    4. I know people did this by calling an ant target from the java application but I don't have
    any sample code, I appreciate any sample code for it.
    Thanks,
    Ali Salehi

    That is an iteresting challenge :)Don't be mean; he's polite, done some investigation and taken the trouble to be clear. The question, presumably, is "has anyone got a different solution or a preference as to which of these is the best?"
    In which case, my advice would be to say that invoking main in a separate thread is fundamentally different from Runtime.exec() because the former would run in the same JVM. Is this what you want? If one app has the other on its classpath then do they need to be separate apps? Could they be modules of a single app?

  • Calling java application from Oracle forms button

    Hi all,
    I have a problem. The idea is to call Java desktop application when button is pressed. I have used this (above) line of code, but there is no results. When I start form in local everything is fine but when I start from server it doesn't work. Does anyone has that kind of problem and how is solved?
    Thanks in advance.
    __Code is:__
    DECLARE
    v_path VARCHAR2(1000);
    BEGIN
    v_path:= '\\location\Java_Application.jar';
    HOST(v_path);
    END;

    First, please start here:
    http://blogs.oracle.com/shay/2007/03/02/
    As for what you are doing and the problem, it will be difficult to give an exact reason, but here are a few comments which will apply regardless of the platform, version, and installation type.
    1. In most case, when calling HOST from Forms the shell that is started does not include all of the system environment variables. This means for example, if a java.exe is needed (on Windows), you would need to specify its path as part of the call or use a batch file rather than calling a command or app directly. The batch file would first set all the needed environment variables (i.e. PATH, CLASSPATH, etc)
    2. If you are running a newer version of Forms, you have a middle tier. This is were your HOST call will be executed. So, if you are expecting this to occur on the client it will not work. You would need WebUtil for client side calls.
    3. Calling a network resource (i.e. shared drive) is not permitted on Windows platforms when called from a Windows Service. Doing so can be seen as a security vulnerability. This can be overridden, but I would suggest that doing so is not a good idea. All files needed to run your app should be made available locally. If files exist on a remote machine, they should be temporarily brought to the machine (e.g. using ftp, sftp, etc) where they are needed and removed later if necessary. If you are running a newer version of Forms, the Forms runtime process belongs to a Windows Service, even if indirectly as a child.
    4. Calling a jar directly is not the proper way to call a java app. Refer to the following:
    http://download.oracle.com/javase/tutorial/deployment/jar/run.html

  • Calling java application from servlet using servletexec servlets

    We are using servletexec 3.0,IIS 5.0, sun Java SDK 1.3.1_12.
    I have a servlet which works fine. This servlet is being called from the submit of the form in a html file.
    It works fine.
    But now i have to use a third party credit card application from my servlet.How can i do that.
    I have added the third party jar files in the classpath of servletexec.
    How can i use their methods.
    Please let me know.

    Something like this ?
    import thirdparty.*;
    import javax.servlet.http.*;
    public class MyServlet extends HttpServlet {
      public void doGet(HttpServletRequest request, HttpServletResponse response) {
        ThirdPartyClass t = new ThirdPartyClass();
        t.someMethod();
    }

  • Calling FPM application from another FPM application

    Hello Experts,
    I've created 2 FPM configurations, one displays the list of POs created by the user through a List UIBB and the other displays the Header and Item of the PO when selected.
    Scenario is that when I should click on the PO (which is a link) in my 1st application, I need to pas the PO number and some other details to my 2nd application and display the PO header and Item. My all Config is purely UIBB based and I'm not using webdynpro at all for designing any views, everything is designed using FPM UIBBs and feeder classes only.
    what I need to know is:-
    1) how can I pass the data between 2 different FPM applications?
    2) how to call and display my 2nd Application on the same page when I click on the link of 1st application? I need the BACK functionality as well.
    3) how to get the data into my 2nd application from 1st application?
    Plz suggest.
    Best Regards
    Jitin Kharbanda

    Jitin,
    The best option in your case would be to open a new browser window with the second application and pass an URL parameter along with the document number.
    Then you can read the URL parameter in the second application. Please see Re: Determining Edit/Display Mode from Within Freestyle Component how this can be achieved.
    Embedding another FPM application into an already opened FPM application (e.g. by embedding a freestyle UIBB and loading the second FPM application from there) won't work as the FPM runtime will cause a dump saying that two instances ofthe FPM are not allowed.
    If you MUST embedd your second application into the first one, the only chance that comes to my mind is the merge the configurations of both applications and pass the data via singleton / wires / events. Please see Data exchange possibilities in Floorplan Manager
    Regards, Uwe

  • Calling web applications from another web application

    Hi everyone,
    I direly need your suggestions on how to implement the following requirements:
    I have a web application (i.e. App A). Then I have other web applications (i.e. App B, App C, App D, etc.) .
    For each of the other apps (App B, App C, App D), I need to have 2 variable/attribute settings whose values are to be set (pre-defined) per user.
    Meaning one user's values are different from another user.
    In App A, I need to call App B, App C, & App D one by one to get the values of the 2 variables/attributes for a particular user accessing App A.
    How should I implement this whole scenario such that I can set the values for 2 variables/attributes in App B, C, & D on a per user basis?
    Please help me get ideas on what methods or work-arounds to implement in order to achieve this.
    Thanks.
    blm

    Assuming this is running on a server, how about placing your data in application scope?
    All applications have access to it. Just make sure every object put in application scope is uniquely named
    and that your other application knows its name. One suggestion is to put a collection object (such as a List) in application scope and add items to it. This way, every application will know the collector's name. They can then search through the collection for any object addressed to itself. Just make sure you send data into and out of the collection in a thread safe way. such as by synchronization.
    Here is an example of an object that you can store in the collection:
    MessageObject{
    String fromApplication;
    String toApplication;
    String message;
    }

  • Calling java application from jsp using onUnload

    I have tried to find the answer to this by searching many jsp, js and java forums, but have not had much luck. I hope someone here can help out. I have written a jsp page that passes a sql string to a java application when it loads. That application creates an xml file (a report) and returns the filename, which is the target of an onclick event. What I want to do, is to delete the file when the page unloads. I have written a separate application that will delete the file, but onclick and onunload events apparently only take JavaScript commands. I have tried to embed the jsp code into an onunload event, but it runs when the page is originally loaded. In addition, I created a separate jsp page that deletes the file, and I call that page onunload using window.open(). I can set that page to self.close(), but I can't get the page to not show itself. Even if I set the height and width to 0 (or 1), it seems to appear 100X100. Can anyone give me any suggestions on what to do in this situation? Thanks.

    When my jsp page loads, I create the file using this code:
    String filename = printtasktest.createxml(closed,encodedSQLString);
    printtasktest is a java application on the server, that
    creates a file on the server, and passes the filename back to the jsp page. Later I use this filename as a target of an onclick event:
    <div class="button" onclick="printTask('<%=filename%>')">Print This Page</div>
    printTask() is a javascript function that opens the printable page using window.print() and self.close().
    The problem I have is that the file hangs around after, and I want to delete it when the user leaves the page.

  • Start java application from another programm

    Hi everyboda on this side,
    i got a big problem. I would like to start out of MS excel an java programm and I would like to hand over data from the MSexcel programm to the java programm. I hope someone can help me. My idea was to create a batchfile, which I start from the excel-programm to run the java programm, but how do I hand over the data from excel to java?
    In advance thanks to all the ones, who tried to help me - max

    You could try to use a JDBC-ODBC bridge that allows you read the data of your excel file.....
    Here, a guide for use it:
    http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/bridge.doc.html
    Hope this helps.

  • Calling Java Application

    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.

    There are different solutions...
    It depends if you have the sourcecode (.java) to the other process or not.
    Then you could implement an interface the could call the main method and let class B call that method.
    anyway, in your case my solution would be REFLECTION!
    e.g
    public void callOtherAppsMain( String[] args )
    Class[] argTypes = new Class[1];
    argTypes[0] = String[].class;
    try
    Method mainMethod = Class.forName( args[0] ).getDeclaredMethod("main", argTypes);
    Object[] argListForInvokedMain = new Object[1];
    argListForInvokedMain[0] = new String[0];
    mainMethod.invoke(null, argListForInvokedMain);
    catch ( Exception ex )
    let me know if you need more code, good luck!

  • Call Java function from multithreaded VC++ application

    Friends, I want to call Java function from two threads of a single VC++ application. I can call it from single thread but when I call it from another thread also, JNI_CreateJavaVM() replies with an error.
    Please......help me

    Your posting is ambiguous. My impression is that you have two threads, both trying to create a java VM?

Maybe you are looking for