EXE EXCECUTION IN JAVA
public void AddAc(String reason) throws IOException, InterruptedException, ClassNotFoundException, SQLException
{
String dt=dateChooserCombo1.getText().trim();
String amt=JOptionPane.showInputDialog("ENTER ...");
ProcessBuilder pb = new ProcessBuilder("C:\\Universe\\Accountmanager\\Accountmanager\\bin\\Debug\\Accountmanager","a",dt,reason,amt);
Process ps = pb.start();
int exitValue=ps.waitFor();
BufferedReader reader;
// System.out.println("Exit Value" + exitValue);
if (exitValue == 0)
{
reader = new BufferedReader(new InputStreamReader(ps.getInputStream()));
}
else
{
reader = new BufferedReader(new InputStreamReader(ps
.getErrorStream()));
}
StringBuilder sb = new StringBuilder();
String temp = reader.readLine();
while (temp != null)
{
sb.append(temp);
temp = reader.readLine();
}
reader.close();
String stat=sb.toString().trim();
if(stat.equalsIgnoreCase("ADDED"))
{
JOptionPane.showMessageDialog(rootPane, "ADDED SUCCESSFULLY FOR THE DATE"+dt);
}
else
{
JOptionPane.showMessageDialog(rootPane, "Execution ERROR...");
System.out.println(stat);
}
}
No comments:
Post a Comment