Looking for Program Executor class in java

Discussion in 'Java' started by Prafulla T, Jan 19, 2007.

  1. Prafulla T

    Prafulla T Guest

    Hello
    I am looking for class which will encapsulate a process(with no GUI)
    and will execute the program
    corresponding to that process.
    What I mean is I am looking for some class which will allow me to
    execute a.out programs ,same way we execute in Shell.
    I am trying to implement it but got no success.
     
    Prafulla T, Jan 19, 2007
    #1
    1. Advertising

  2. In article <>,
    "Prafulla T" <> wrote:

    > Hello
    > I am looking for class which will encapsulate a process(with no GUI)
    > and will execute the program
    > corresponding to that process.
    > What I mean is I am looking for some class which will allow me to
    > execute a.out programs ,same way we execute in Shell.
    > I am trying to implement it but got no success.


    Did you look at Runtime.exec? Or at Java 5's new ProcessBuilder?
    --
    Steve W. Jackson
    Montgomery, Alabama
     
    Steve W. Jackson, Jan 19, 2007
    #2
    1. Advertising

  3. Prafulla T

    Alex Hunsley Guest

    Prafulla T wrote:
    > Hello
    > I am looking for class which will encapsulate a process(with no GUI)
    > and will execute the program
    > corresponding to that process.
    > What I mean is I am looking for some class which will allow me to
    > execute a.out programs ,same way we execute in Shell.
    > I am trying to implement it but got no success.


    What did you try so far? Give more details than just "got no success".
    System.exec could be what you need, as the other replier said.

    >
     
    Alex Hunsley, Jan 19, 2007
    #3
  4. Prafulla T

    Prafulla T Guest

    On Jan 19, 2:28 pm, Alex Hunsley <> wrote:
    > Prafulla T wrote:
    > > Hello
    > > I am looking for class which will encapsulate a process(with no GUI)
    > > and will execute the program
    > > corresponding to that process.
    > > What I mean is I am looking for some class which will allow me to
    > > execute a.out programs ,same way we execute in Shell.
    > > I am trying to implement it but got no success.

    >
    > What did you try so far? Give more details than just "got no success".
    > System.exec could be what you need, as the other replier said.
    >
    >
    >
    > - Hide quoted text -
    >
    > - Show quoted text -


    Do you know what system("any executable") function does in C?
    It simply executes command passed to it.
    No need to take any OutputStream and InputStream.
    I want such a thing in Java.
    I want to be able to execute a process and OutputStream should be
    Stdout & InputStream should be stdin.
    You know how to do it???
     
    Prafulla T, Feb 7, 2007
    #4
  5. On 7 Feb 2007 09:53:06 -0800, Prafulla T wrote:
    > Do you know what system("any executable") function does in C? It
    > simply executes command passed to it. No need to take any
    > OutputStream and InputStream. I want such a thing in Java. I want to
    > be able to execute a process and OutputStream should be Stdout &
    > InputStream should be stdin.


    Java's mechanisms for executing child processes (Runtime.exec() and
    java.lang.ProcessBuilder) do not let the child share the same input
    and output streams as the Java application itself.

    The child's streams are always connected through streams available
    through a Process object. As such, these mechanisms more closely
    resemble p2open() (or popen()) than system().

    /gordon

    --
    [ don't email me support questions or followups ]
    g o r d o n + n e w s @ b a l d e r 1 3 . s e
     
    Gordon Beaton, Feb 7, 2007
    #5
  6. Prafulla T

    Chris Uppal Guest

    Prafulla T wrote:

    > Do you know what system("any executable") function does in C?
    > It simply executes command passed to it.
    > No need to take any OutputStream and InputStream.
    > I want such a thing in Java.
    > I want to be able to execute a process and OutputStream should be
    > Stdout & InputStream should be stdin.


    As far as I know (and I'd be very pleased to be shown I'm wrong) there is no
    way
    (short of using JNI) that you can execute a external program from Java and have
    it inherit its stdin/stdout/stderr from the parent process.

    The best I can think of is to attach threads to each of the external process's
    streams which forward to/from the corresponding System.out/err/in. And that,
    unfortunately, is not quite the same...

    -- chris
     
    Chris Uppal, Feb 7, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. iksrazal

    Cancelling an Executor thread

    iksrazal, Jun 21, 2004, in forum: Java
    Replies:
    0
    Views:
    792
    iksrazal
    Jun 21, 2004
  2. Kenneth P. Turvey

    Executor

    Kenneth P. Turvey, Sep 19, 2005, in forum: Java
    Replies:
    8
    Views:
    851
    Kenneth P. Turvey
    Sep 20, 2005
  3. howa
    Replies:
    8
    Views:
    2,587
  4. Rakesh
    Replies:
    1
    Views:
    550
    Knute Johnson
    Oct 13, 2008
  5. Tom Anderson
    Replies:
    12
    Views:
    695
    Daniel Pitts
    Jan 21, 2010
Loading...

Share This Page