View Single Post
Old 01-21-2009, 05:44 AM   #109
elinares
Xtreme Quijote
elinares doesn't litterelinares doesn't litterelinares doesn't litter
 
elinares's Avatar
 
Posts: 101
Karma: 208
Join Date: Sep 2008
Location: La Mancha, Spain
Device: Sony PRS-505
Quote:
Originally Posted by Gudy View Post
WaitAMinute. Wait. Just. A. Minute.

Did I understand that right? You're using a GUI written in Java to call another program, also written in Java, and you're calling "jave.exe -jar" directly by either Runtime.getRuntime().exec() or ProcessBuilder()?! That strikes me as, sorry for the language, bass ackwards.

Why not just directly call the main() method of the main class from the LRFTools jar with the arguments as a string array instead? It's nice, clean, simple, and most of all, platform independent. If you don't want to wait for the program to return, use a separate thread to run the LRFTools from the GUI...
Yep, this is better than spawnning a new process. You can call lrf.RecurseDirs.main(String args[]), args holding the command-line parameters on a fresh thread to do the work.

Also, if you want to see progress, before calling to the above static method; you can assign to System.out and System.err two new PrintStreams, and then periodically show their contents to a frame on your GUI.

Thanks to all,
Eladio
elinares is offline   Reply With Quote