• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

input data for external program

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic