F
freesoft_2000
Hi everyone,
I am using the Runtime class to run a java program by
using the java intreperter.
This is what i am doing to get the output stream of the java program
String str18 = //The string to run the java program with the java
intreperter
String str20 = null;
Runtime Runtime1 = Runtime.getRuntime();
Process Process1 = Runtime1.exec(str18);
//This is the line where i am trying to get the output stream of the java
//program by getting its inputstream. I am right am i not or do i have
//to get its outputstream of the program instead
BufferedReader in = new BufferedReader(new
InputStreamReader(Process1.getInputStream()));
while ((str20 = in.readLine()) != null)
{
System.out.println(str20);
}
Process1.waitFor();
Now this is the java program i am running
public class JTest
{
public static void main(String args[])
{
int i = 0;
for(i=0;i<5;i++)
{
System.out.println("This is ouput " + i);
}
}
}
The thing is the java program runs and everything is alright but i am not
getting its console output by the way i am doing it.
I am right in that to get the output of a program, i get its inputstream
and not outputstream right?
I am also using threads to run the program but that should have no effect
right?
If what i am doing is wrong could someone guide me on the right way to get
the output stream of a program
Any help is greatly appreciated
Thank You
Yours Sincerely
Richard West
I am using the Runtime class to run a java program by
using the java intreperter.
This is what i am doing to get the output stream of the java program
String str18 = //The string to run the java program with the java
intreperter
String str20 = null;
Runtime Runtime1 = Runtime.getRuntime();
Process Process1 = Runtime1.exec(str18);
//This is the line where i am trying to get the output stream of the java
//program by getting its inputstream. I am right am i not or do i have
//to get its outputstream of the program instead
BufferedReader in = new BufferedReader(new
InputStreamReader(Process1.getInputStream()));
while ((str20 = in.readLine()) != null)
{
System.out.println(str20);
}
Process1.waitFor();
Now this is the java program i am running
public class JTest
{
public static void main(String args[])
{
int i = 0;
for(i=0;i<5;i++)
{
System.out.println("This is ouput " + i);
}
}
}
The thing is the java program runs and everything is alright but i am not
getting its console output by the way i am doing it.
I am right in that to get the output of a program, i get its inputstream
and not outputstream right?
I am also using threads to run the program but that should have no effect
right?
If what i am doing is wrong could someone guide me on the right way to get
the output stream of a program
Any help is greatly appreciated
Thank You
Yours Sincerely
Richard West