• Post Reply Bookmark Topic Watch Topic
  • New Topic

input data for external program  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to launch an external fortran executable from Java. To launch from the command line I would type "programName (space) path to input dataset" and this would bring up the already loaded (with data) application. I am able to launch a standard executable (without the input file name) using ProcessBuilder but if I try to include the input file name it does bring up the application until I quit the java program that executed the ProcessBuilder call.

I thought of trying ProcessBuilder.Redirect.from to input the data file name but I do not understand how to use this class and I do not have an example.

Any help would be appreciated.
 
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David, and welcome to the Ranch!

I'm only guessing now, since you didn't provide the source code. Common mistake when running external processes from Java is the failure to consume standard output and error stream of the external process. Your issue might belong to the same class. Please read this (somewhat lenghty) article, it should help you to execute an external program flawlessly.

If this does not help, post the relevant code here. We'll try to have a look at it.
 
David Wilkinson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Martin,

Thank you for your reply. I have indeed read that article and a few others beside and I am aware of the need for maybe taking care of possible output from the executed program.

The following code snippet is from my program and is what happens as a result of a button press in the main program:







If I leave the StreamGobbler calls in then the program never advances past that point. If I remove these lines (as shown) then the program does start up the "executable" but does not display it untill I exit the main program.

Cheers, Dave
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!