Results 1 to 4 of 4
  1. #1
    collin389 is offline Senior Member
    Join Date
    Nov 2009
    Posts
    235
    Rep Power
    6

    Default help with Runtime.getRuntime().exec

    Hey, I am trying to run another java program from mine using Runtime.getRuntime().exec.
    In my program I call a function that is supposed to append text to a JTextArea, then run Process p = Runtime.getRuntime().exec( java -cp ... );
    I have two problems, the first is that It runs the java program FIRST, and when the java program is done, it appends the text.
    The second problem is that the parent program hangs until the second one is done. How can I fix these problems? Thanks.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Sounds like you'll need to create and use a SwingWorker object to allow background processes to work well with Swing. Please read this tutorial on the Swing EDT and how to run background processes: Concurrency in Swing

    Also, this is really a Swing question, and so I am going to move this to the Swing forum.

    Much luck!

  3. #3
    collin389 is offline Senior Member
    Join Date
    Nov 2009
    Posts
    235
    Rep Power
    6

    Default

    Thanks again for your help Fubarable!

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. problem with Runtime.getRuntime().exec when running java in .bat
    By Shayko in forum Threads and Synchronization
    Replies: 2
    Last Post: 01-27-2010, 08:46 PM
  2. Problem with Runtime.getRuntime().exec with Linux Commands
    By swapnilnawale in forum Threads and Synchronization
    Replies: 1
    Last Post: 09-23-2009, 11:23 PM
  3. Replies: 3
    Last Post: 04-02-2009, 09:16 PM
  4. grep on multiple files using Runtime.getRuntime().exec()
    By cprash.aggarwal in forum Advanced Java
    Replies: 3
    Last Post: 02-11-2009, 07:55 AM
  5. Replies: 6
    Last Post: 12-29-2008, 03:47 PM

Posting Permissions

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