hi everyone!
I want to get the output of my c++ application from my jaca applacations o i use a file abs.bat to get it done
i used this code in .bat:
start readxmlresou.exe
that commande line opens readxmlresou.exe that is in my desktop and execute it, now i want to get the output of that application to my application java, i wrote this code but i doesn't work:
public Process DoSysCommand(boolean bWait) throws IOException
{
Runtime runtime1 = Runtime.getRuntime();
final Process process = runtime1.getRuntime().exec(new String[]{"C:\\Users\\abdelhalim\\Desktop\\abs.bat", "readxmlresou.exe"}, null, new File("C:\\Users\\abdelhalim\\Desktop\\"));
process.getInputStream();
OutputStream out = null;
InputStream in= null;
// Consommation de la sortie standard de l'application externe dans un Thread separe
new Thread() {
public void run() {
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = "";
try {
while((line = reader.readLine()) != null) {
// Traitement du flux de sortie de l'application si besoin est
System.out.println("line="+ line);
}
} finally {
reader.close();
}
} catch(IOException ioe) {
ioe.printStackTrace();
}
}
}.start();
// Consommation de la sortie d'erreur de l'application externe dans un Thread separe
new Thread() {
public void run() {
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
String line = "";
try {
while((line = reader.readLine()) != null) {
// Traitement du flux d'erreur de l'application si besoin est
}
} finally {
reader.close();
}
} catch(IOException ioe) {
ioe.printStackTrace();
}
}
}.start();
try
{
process.getInputStream();
if(bWait)
{
process.waitFor();
}
}
catch(InterruptedException e)
{
System.err.println(e.getMessage());
}
return process;
}
}
what i get when i press the button in the GUI in java is the readxmlresou.exe ( the console vs2010 c + + shows the output of the c++ application) and then it bloked there , the 2 applications bloked in this stage,even c + + application does not close
I will try to figure it out , so if YOU have any idea about that ,I am really very grateful for your help