|
-
September 23rd, 2000, 06:19 PM
#1
HELP!!! This is about the exec method...
Hi!
I am trying to run a fortran exe. I have posted the code below. The program works fine when I run notepad instead of the fortran exe!
The fortran program runs fine when run independantly. So, as long as they are running independantly, they run fine but when integrated ...
I have been battling with this problem for some time and decided that it was time to get help!
I am waiting for the process to be done, reading from the created process ... all that needs to be done in order to have a successful run!!!
FYI-The fortran program reads input data from a file.
Thanks.
import java.io.*;
public class ExecPgm
{
public static void main (String[] args)
{
try
{
Process p;
BufferedReader br;
try
{
p = Runtime.getRuntime().exec("for.exe");
p.waitFor();
int complete = p.exitValue();
System.out.println("complete status "+ complete);
if ( complete == 1 )
{
System.out.println("Bailing out...");
return;
}
br = new BufferedReader(new InputStreamReader(p.getInputStream()));
}catch(InterruptedException g){System.err.println(g);}
String outLine;
System.out.println(p);
//END is the last output from the fortran program
while ("END" != (outLine = br.readLine()))
{
System.out.println(outLine);
//I was forced to put this!
if((outLine == null)||(outLine == ""))
return;
}
br.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|