Calling another application from a java program

Hi, Java ppl.
I wanted to know how can I call another program say a help application or an exe from a java program. anyone with any advice or a piece of code would help.
Thanks
Pradeep

I had the same situation and I tried the code that you sugested and it works. I was wondering, what am I expecting in the while loop that appears after the int inp; statement? Is some data going to be displayed on the screen? How essential is to have that while loop after the calling the exec() method?
Sorry for the amount of questions, I never tried this before.
Best regards,
Luis E.

Similar Messages

  • Calling another class from a java program

    I tried to call the Server1.class from the password program, but I failed. The password program source code is as follows:
    class PasswordDialog extends java.awt.Dialog implements java.awt.event.ActionListener
         * Constructor. Create this visual dialog component.
         public PasswordDialog(java.awt.Frame parent, PasswordVerifier verifier)
              super(parent);
              addWindowListener(new WindowEventHandler());
              setLayout(new java.awt.FlowLayout());
              setSize(500, 100);
              this.verifier = verifier;
              add(useridField = new java.awt.TextField(10));
              add(passwordField = new java.awt.TextField(10));
              add(okButton = new java.awt.Button("Submit"));
              add(cancelButton = new java.awt.Button("Cancel"));
              okButton.addActionListener(this);
              cancelButton.addActionListener(this);
              passwordField.setEchoChar('*');
              useridField.requestFocus();
         public void actionPerformed(java.awt.event.ActionEvent e)
              if (e.getSource() == okButton)
                   // Invoke password verification callback
                   try
                        boolean result = verifier.verifyPassword(
                             useridField.getText(), passwordField.getText());
                        if (! result) return;     // verification failed; don't close this dialog
                   catch (Exception ex)
                        ex.printStackTrace();
                   // Close this dialog
                   System.out.println("I still can't call the Server1 class");
                   dispose();
              else if (e.getSource() == cancelButton)
                   dispose();
         class WindowEventHandler extends java.awt.event.WindowAdapter
              public void windowClosing(java.awt.event.WindowEvent e)
                   System.exit(0);
         // Private objects
         private PasswordVerifier verifier;
         private java.awt.TextField useridField;
         private java.awt.TextField passwordField;
         private java.awt.Button okButton;
         private java.awt.Button cancelButton;
    interface PasswordVerifier
         public boolean verifyPassword(String userid, String password) throws Exception;
    public class password implements PasswordVerifier
         * Main routine for testing only.
         public static void main(String[] args)
              password verifier = new password();
              java.awt.Frame f = new java.awt.Frame("Password Verifier");
              f.setSize(100, 100);
              f.show();
              PasswordDialog d = new PasswordDialog(f, verifier);
              d.show();
         public boolean verifyPassword(String userid, String password) throws Exception
              return (userid.equals("Albert") && password.equals("Einstein"));
    and the Server1.java is as follows:
    //Server Application
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.io.*;
    public class Server1 extends Frame implements ActionListener,Runnable,KeyListener
    ServerSocket s;
    Socket s1;
    BufferedReader br;
    BufferedWriter bw;
    TextField text;
    TextField name;
    Button exit,clear;
    Label label;
    List list;
    Panel p1=null;
    Panel p2=null;
    Panel sp21=null;
    Panel sp22=null;
    Panel jp=null;
    public void run()
              try{s1.setSoTimeout(1);}catch(Exception e){}
              while (true)
                   try{
    list.add(br.readLine());
                   }catch (Exception h){}
    if(list.getItemCount()==7)
    list.remove(0);
    public Server1(String m)
    {       super(m);
    jp=new Panel();
    p1=new Panel();
    p2=new Panel();
    sp21=new Panel();
    sp22=new Panel();
    jp.setLayout(new GridLayout(2,1));
    p1.setLayout(new GridLayout(1,1));
    p2.setLayout(new GridLayout(2,1));
    sp21.setLayout(new FlowLayout());
    sp22.setLayout(new FlowLayout());
    exit = new Button("Exit");
    clear = new Button("Clear");
    exit.addActionListener(this);
    clear.addActionListener(this);
    list = new List(50);
    text = new TextField(43);
    name = new TextField(10);
    label = new Label("Enter your name");
    name.addKeyListener(this);
    text.addKeyListener(this);
    p1.add(list);
    sp21.add(text);
    sp21.add(exit);
    sp22.add(label);
    sp22.add(name);
    sp22.add(clear);
    p2.add(sp21);
    p2.add(sp22);
    jp.add(p1);
    jp.add(p2);
    this.add(jp);
    setBackground(Color.orange);
    setSize(380,300);
    setLocation(0,0);
    setVisible(true);
    setResizable(false);
    name.requestFocus();
    try{
    s = new ServerSocket(786);
                   s1=s.accept();
                   br = new BufferedReader(new InputStreamReader(
                             s1.getInputStream()));
                   bw = new BufferedWriter(new OutputStreamWriter(
                             s1.getOutputStream()));
    bw.write("Welcome");bw.newLine();bw.flush();
                   Thread th;
                   th = new Thread(this);
                   th.start();
              }catch(Exception e){}
    public static void main(String args[])
    new Server1("Server");
         public void actionPerformed ( ActionEvent e)
    if (e.getSource().equals(exit))
                   System.exit(0);
    else if (e.getSource().equals(clear))
    { name.setText(" ");
    name.setEditable(true);
    public void keyPressed(KeyEvent ke) {
    if(text.equals(ke.getSource()))
    if(ke.getKeyCode()==KeyEvent.VK_ENTER)
    try{
    bw.write(name.getText()+">>"+text.getText());
                   bw.newLine();bw.flush();
                   }catch(Exception m){}
    list.add(name.getText()+">>"+text.getText());
    text.setText("");
    else if(name.equals(ke.getSource())) {
    if(ke.getKeyCode()==KeyEvent.VK_ENTER)
    name.setEditable(false);
    text.requestFocus();
    public void keyReleased(KeyEvent ke)
    //something
    public void keyTyped(KeyEvent ke)
    //something
    I tried to create a new object by typing:
    Server1 s = new Server1();
    then call the main function
    new Server1("Server");
    but it doesn't work. Anybody can help me with this?

    try
    Server1 s = new Server1();
    s.Server1("Server");
    or
    new Server1().Server1("Server");

  • Possibility of calling standard actions from a java program

    Hi ,
    I am working for a project where customer wants to have option of saving orders as draft only and later convert to order if need be. However since we do not want many drafts to reside on server there is a need to delete these at a specified time. For draft orders I am using order templates since they stay in the database without getting converted to orders. Now I do not know how to go about the deletion part.
    i need to write a program that would run on the server and which would fetch the templates (drafts) that have been created till a particular time and call the delete action of the template. Now the question is how do i call these actions from a java program where this java program will have to run on the server end (ie will be a backend process).
    Please suggest.
    Thanks
    Roopali

    hello roopali,
    you can create a separate thread that will run your
    code that will check for stale drafts and delete them.
    it is just like a session management program but here
    we will be looking over the drafts and not the session
    objects.
    now if you want the invocation of the action from another
    program, a socket program would suffice but opening ports
    will cause you network connections thru firewall.
    if you can make use of HTTP servlet as your service
    provider e.g., you can then just pass some action params
    to invoke it.
    regards
    jo

  • Calling OCX Methods from a Java Program

    Hi All,
    Is it possible to call OCX methods from a Java program? If yes, can you please refer me to any documents or sample code to achieve this.
    All inputs are highly appreciated.
    Thanks
    Tarek

    JNI
    http://java.sun.com/docs/books/tutorial/native1.1/index.html

  • Calling a servlet from a java program

    I could not find a forum for servlet hence am posting
    here
    I have a servlet that accepts prameters and
    gives some out put .
    I want to be able to call this servlet ( invoke )
    from a Java Program .
    How do i do that ..
    Any sample code /pointer would be appreciated.
    Deepa

    hi
    you can try this code.
    URL url = new URL("http://localhost:8888/yourServlet?param1=value1");
    URLConnection con = url.openConnection();
    StringBuffer sBuf = new StringBuffer();
    BufferedReader bReader = new BufferedReader(
    new InputStreamReader(
    con.getInputStream()));
    String line = null;
    while((line = bReader.readLine()) != null) {
    sBuf.append(line);
    System.out.println(sBuf);
    hope this helps
    Shrini

  • Calling jsp page from a java program

    Hello,
    Is it possible to call a JSP page from a java program? If so, please let me know how it is possible.
    I have a JSP page that inserts 10 records in a database based on the attribute given to the page. When the java program is executed all the 10 records need to be inserted.
    The JSP page is already running fine in Tomcat.
    Thanks and Regards,
    Prasanna.

    MVC has applied the standard of seperate your view , model and controller. I believe nobody will insert data from jsp page,better practice should be inserted from your database layer, normally is like DAO layer. so you should pass your data from jsp to your backend.
    hopefully it's help u

  • Calling an executable from a java program

    How can I call a compiled program from a java program. I have a fortran program, which I would like to call for execution from within my java program. My OS is linux.
    Thanks,
    An

    Not quite sure in the case of fortran program, but one thing can be done, call ur fortran program from a batch (.bat file) and call this .bat file from java ;
    try {
    Process p = Runtime.getRuntime().exec("run.bat");
    p.waitFor();
    catch( Exception e ) {
    }

  • Call ODI Scenario from a Java Program

    Hi,
    I would like to invoke the ODI Scenario from a Java Program. Is there any way i can do this?
    Please let me know if you have any posts related to this.
    Thanks,
    Mansur

    Check this ..
    How to run ODI scenario from java?

  • How to open another application from a java programme

    How can I open some other application like "Textpad"
    from a java programme.
    Actually I want to open a particular java file in Textpad editor from my java programme.
    How Can I do that?
    Thanks

    Thanks for the code,
    I tried that but got this error
    java.io.IOException: CreateProcess: C://ProgramFiles/TextPad4/TextPad.exe D://Pi
    yush/BeanCreator/Parts.java error=3
    at java.lang.Win32Process.create(Native Method)
    at java.lang.Win32Process.<init>(Win32Process.java:64)
    at java.lang.Runtime.execInternal(Native Method)
    at java.lang.Runtime.exec(Runtime.java:272)
    at java.lang.Runtime.exec(Runtime.java:195)
    at java.lang.Runtime.exec(Runtime.java:152)
    at pack.CreateBean.CreateFile(CreateBean.java:327)
    Any idea!! What that means

  • When I am on a phone call and I double click the button to go to my home screen, then open another application (usually my calendar program, Calengoo), my screen goes blank and I am not able to return to either the app, the phone, or the home screen.

    When I am on a phone call and I double click the button to go to my home screen, then open another application (usually my calendar program, Calengoo), my screen goes blank and I am not able to return to either the app, the phone, or the home screen. If I am speaking to a person, if they hang up then I am back to the phone application. If I'm leaving a message, I am unable to return to the phone screen to end the call, and have to wait until the other phone hangs up. I'm also unable to switch back and forth to look at my calendar if I'm calling someone about scheduling. This has only started happening since the most recent iOs update. I run into situations similar to this about once per day during the work week, as I use my phone is this manner quite often. While not life altering it is quite frustrating. Can anyone here help me figure out a way to avoid this? If it helps, I have noticed a general downgrade in overall performance starting two system updates ago (apps opening more slowly, closing unexpectedly more often, etc.). I have an iPhone 3GS with the latest OS update.
    Thank you for any help or suggestions,
    Chris

    I could be corrupted backup.
    You can check the notification settings for message.
    Settings>Notification Center>Messages>Alert Style
    It should be on Banners or Alerts.
    Settings>Messages> Turn on Imessage and send as SMS and below that "Blocked" to check if you have any numbers block might be blocking the message.
    You can also do a hard reset by holding power and home till it restarts and release after seeing the apple logo.
    Still doesn't work? Settings>General>Reset>Reset all settings

  • Calling servlet from a java program

    Hi
    I need to call a servlet's doPost() method from a java program. I have a specific situation, where I need to call servlet from a java program. DUring this call I need to pass a file and two string to the servlet. Servelt after receiving the file and string uploads the file to the server at a specified location. I am stuck up as how to call servlet from a java program instead of a HTML or JSP.
    Can anyone help me to start with this.
    any suggestion is welcome.

    You have to establish a URLConnection with servlet from your java program.
    URL servletURL = new URL("http://localhost:8080/Myservlet?str1=abc&str2=def");
    URLConnection servletConnection = servletURL.openConnection();you can get the objectOutputStream
    ObjectOutputStream oos = new ObjectOutputStream (servletConnection.getOutputStream());
    oos.writeObject(your file object);-------------------------------------------------
    In the servlet u can get the strings using request.getParameter("str1");
    In the servlet u can get the strings using request.getParameter("str2");
    file = new ObjectInputStream (request.getInputStream()).readObject()a lot of resources are available on this ...
    hope this helps :)

  • Cannot call ANY stored functions from my Java program

    My problem is that I cannot call ANY stored procedure from my Java
    program. Here is the code for one of my stored procedures which runs
    very well in PL/SQL:
    PL/SQL code:
    CREATE OR REPLACE PACKAGE types AS
    TYPE cursorType IS REF CURSOR;
    END;
    CREATE OR REPLACE FUNCTION list_recs (id IN NUMBER)
    RETURN types.cursorType IS tracks_cursor types.cursorType;
    BEGIN
    OPEN tracks_cursor FOR
    SELECT * FROM accounts1
    WHERE id = row_number;
    RETURN tracks_cursor;
    END;
    variable c refcursor
    exec :c := list_recs(11)
    SQL> print c
    COLUMN1 A1 ROW_NUMBER
    rec_11 jacob 11
    rec_12 jacob 11
    rec_13 jacob 11
    rec_14 jacob 11
    rec_15 jacob 11
    Here is my Java code:
    import java.sql.*;
    import java.io.*;
    import oracle.jdbc.driver.*;
    class list_recs
    public static void main(String args[]) throws SQLException,
    IOException
    String query;
    CallableStatement cstmt = null;
    ResultSet cursor;
    // input parameters for the stored function
    String user_name = "jacob";
    // user name and password
    String user = "jnikom";
    String pass = "jnikom";
    DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
    try { Class.forName ("oracle.jdbc.driver.OracleDriver"); }
    catch (ClassNotFoundException e)
    { System.out.println("Could not load driver"); }
    Connection conn =
    DriverManager.getConnection (
    "jdbc:oracle:thin:@10.52.0.25:1521:bosdev",user,pass);
    try
    String sql = "{ ? = call list_recs(?) }";
    cstmt = conn.prepareCall(sql);
    // Use OracleTypes.CURSOR as the OUT parameter type
    cstmt.registerOutParameter(1, OracleTypes.CURSOR);
    String id = "11";
    cstmt.setInt(2, Integer.parseInt(id));
    // Execute the function and get the return object from the call
    cstmt.executeQuery();
    ResultSet rset = (ResultSet) cstmt.getObject(1);
    while (rset.next())
    System.out.print(rset.getString(1) + " ");
    System.out.print(rset.getString(2) + " ");
    System.out.println(rset.getString(3) + " ");
    catch (SQLException e)
    System.out.println("Could not call stored function");
    e.printStackTrace();
    return;
    finally
    cstmt.close();
    conn.close();
    System.out.println("Stored function was called");
    Here is how I run it, using Win2K and Oracle9 on Solaris:
    C:\Jacob\Work\Java\Test\Vaultus\Oracle9i\FunctionReturnsResultset>java
    list_recs
    Could not call stored function
    java.sql.SQLException: ORA-00600: internal error code, arguments:
    [ttcgcshnd-1], [0], [], [], [], [], [], []
    at
    oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
    at oracle.jdbc.ttc7.TTC7Protocol.fetch(TTC7Protocol.java:889)
    at
    oracle.jdbc.driver.OracleStatement.<init>(OracleStatement.java:490)
    at
    oracle.jdbc.driver.OracleStatement.getCursorValue(OracleStatement.java:2661)
    at
    oracle.jdbc.driver.OracleStatement.getObjectValue(OracleStatement.java:4189)
    at
    oracle.jdbc.driver.OracleStatement.getObjectValue(OracleStatement.java:4123)
    at
    oracle.jdbc.driver.OracleCallableStatement.getObject(OracleCallableStatement.java:541)
    at list_recs.main(list_recs.java:42)
    C:\Jacob\Work\Java\Test\Vaultus\Oracle9i\FunctionReturnsResultset>
    Any help is greatly appreciated,
    Jacob Nikom

    Thank you for your suggestion.
    I tried it, but got the same result. I think the difference in the syntax is due to the Oracle versus SQL92 standard
    conformance. Your statament is the Oracle version and mine is the SQL92. I think both statements are acceptable
    by the Oracle.
    Regards,
    Jacob Nikom

  • 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.

  • How to run a remote application (Non Java) from a Java program

    Could you please tell me how to run a remote application (Non-Java) from a Java program without using RMI. Please tell me know the procedure and classes to be used.
    Cheers
    Ram

    what do you mean remote application.In the other pc or in your pc just apart from you application?
    If the application is in your pc,the method which the upper has mentioned is
    a good one!
    But if the application you want to run is not in your computer,the method can't do. And you can use socket with which you can build an application listening some port in the pc which contains the application you want to run .When you want to run that application ,send the Start_Command to the listening application.Then listening application will run the application with the help of the method the upper mentioned.

Maybe you are looking for

  • Mini display port not working?

    I am trying to connect my late 2009 iMac to an extenal monitor.  Been to store twice now and both adapters are not fitting???  Am I missing something here... Thanks

  • Howto? SSO server calls through proxy (not reverse)

    I developed an authentication plugin for Oracle SSO Server (10g 9.0.0.4). This plugin initiates HTTP requests to an external authentication server somewhere on the internet. How do I configure the SSO server (or apache or OC4J, at least somewhere) th

  • Ssrs 2008 and Kerberos both work separately; but not together

    Sorry that this question is very similar to some others that have been asked on this forum. Unfortunately, none of the solutions I've been able to find here or elsewhere have solved my problem. I'm trying to create some reports on data in a SharePoin

  • Is there a way to save InDesign CS6's help files to hard drive for access off-line?

    I can't figure out how to do this. I often take my laptop where there is no internet or weak internet. Help doesn't work when I'm there. Surely there's a way to do this, right? How? I'm using the Middle Eastern version 8.0.2 (Hebrew-English). I need

  • Problem while generating hindi pdfs

    Hi, This is Dasaradh. I have one problem while generating pdfs in HIndi. Here i have used two properties files, one is English and another one is Hindhi. If the user selects English PDF is generates Suceesfully. But if the user selects hindhi then pd