Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-09-2009, 03:38 AM
Senior Member
 
Join Date: Nov 2009
Posts: 205
Rep Power: 1
collin389 is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 11-09-2009, 03:44 AM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,492
Rep Power: 8
Fubarable is on a distinguished road
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!
__________________
When posting code, please use code tags so that your code is readable. To do this, place the tag [code] before your block of code and [/code] after your block of code.
How to use Code Tags
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-09-2009, 05:09 AM
Senior Member
 
Join Date: Nov 2009
Posts: 205
Rep Power: 1
collin389 is on a distinguished road
Default
Thanks again for your help Fubarable!
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 11-09-2009, 05:22 AM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,492
Rep Power: 8
Fubarable is on a distinguished road
Default
You're quite welcome!
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with Runtime.getRuntime().exec when running java in .bat Shayko Threads and Synchronization 2 01-27-2010 08:46 PM
Problem with Runtime.getRuntime().exec with Linux Commands swapnilnawale Threads and Synchronization 1 09-23-2009 11:23 PM
To start external program with Runtime.getRuntime().exec(...) in foreground tilex AWT / Swing 3 04-02-2009 09:16 PM
grep on multiple files using Runtime.getRuntime().exec() cprash.aggarwal Advanced Java 3 02-11-2009 07:55 AM
help with "Runtime.getRuntime().exec(this.command);" itaipee New To Java 6 12-29-2008 03:47 PM


All times are GMT +2. The time now is 07:48 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org