Results 1 to 4 of 4

Thread: runtime.exec

  1. #1
    cotede2 is offline Member
    Join Date
    Apr 2009
    Posts
    3
    Rep Power
    0

    Default runtime.exec

    Hello there,

    I'd like to call an external program from a java application.
    I know we can do this that way :

    PHP Code:
    Runtime runtime = Runtime.getRuntime();
            try {
                String userId = this.context.getUserType();
                runtime.exec(new String[]{"C:\\prog.exe"});
            } catch (IOException ex) {
                ex.printStackTrace();
            }
    or we can add some arguments :

    PHP Code:
             runtime.exec(new String[]{"C:\\prog.exe","arg1"});
    but my dos call is like this :

    PHP Code:
    Edition_badges -argName="argValue"
    the important thing here is the -argName.
    How can I do that with exec?

  2. #2
    cotede2 is offline Member
    Join Date
    Apr 2009
    Posts
    3
    Rep Power
    0

    Default

    my idea was to make this :
    Runtime runtime = Runtime.getRuntime();
    try {
    String userId = this.context.getUserType();
    runtime.exec(new String[]{"C:\\pour_Franck\\Edition_Badges.exe","-ClauseWhereDefaut=V_TP_INVITE_CAT.USR_TYPE = "+userId});
    } catch (IOException ex) {
    ex.printStackTrace();
    }
    is it good?

  3. #3
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    Did you try it?
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  4. #4
    cotede2 is offline Member
    Join Date
    Apr 2009
    Posts
    3
    Rep Power
    0

Similar Threads

  1. help with Runtime.exec()
    By Lanfear in forum New To Java
    Replies: 18
    Last Post: 12-16-2008, 11:09 AM
  2. runtime.exec stale process
    By karine in forum Advanced Java
    Replies: 6
    Last Post: 10-06-2008, 05:40 PM
  3. Tomcat and Runtime.exec
    By karine in forum Introductions
    Replies: 1
    Last Post: 10-03-2008, 08:25 AM
  4. Runtime.exec()
    By hknyo in forum Advanced Java
    Replies: 2
    Last Post: 08-16-2008, 12:40 AM
  5. Problem with Runtime.exec()
    By nhabibi in forum Advanced Java
    Replies: 11
    Last Post: 07-02-2008, 01:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •