This discussion is archived
2 Replies Latest reply: Jun 12, 2013 12:27 PM by rp0428 RSS

Process (.exe) run from java

AnjanN Newbie
Currently Being Moderated

Hi all,

  I need to run a ".exe" from my .java file. I have developed a sample Swing GUI application that calls a ".exe" from my program. The application contains a dialog box. The dialog contains a text box and a button. When user will enter some number in the text box and hits the button a ".exe" will be called. That ".exe" in turn will perform a DB activity, fire some sql queries and insert some data into the database. The 32 bit ".exe" is built in Visual studio and developed by C++.

 

The problem is that when I am entering some number and pressing the button, the ".exe" file is invoked and the process starts running, but I could not be able to see the data that is inserted into the database after the tested time of process run. I could see the data in table only when I quit my java swing application by closing the dialog.

 

What I mean by tested time of process run is that, I have tested the ".exe" separately by running the same from a batch file. That is running fine and data is inserted into database like a charm. I want the same from java code.

 

Programmatically what I did to run the .exe is as follows:

 

String[] cmdArray = new String[3];
cmdArray[0] = "testRun.exe";
cmdArray[1] = "some args";
cmdArray[2] = "some args";
Process process = Runtime.getRuntime().exec(cmdArray,null);

 

It will be of great help if anybody can figure out where the actual problem is.

 

My program is not even multithreaded. The whole thing is written inside the main thread itself as in normal case.

 

Thanks in Advance.....