Dealing with exceptions in my simple GUI app involving a process
Hey there,
Been using Java for a while now, but haven't learned everything so I started trying out Runtime and Processes and I am stuck in a dilema right now. Also not quite sure if this is the right forum.
Code:
Runtime rt = Runtime.getRuntime();
try {
Process p = rt.exec("notepad.exe " + file.getPath());
// int exitVal = p.waitFor();
p.waitFor();
// System.out.println("ExitValue: " + exitVal);
// code for testing in a console
BufferedReader outStream = new BufferedReader(new InputStreamReader(p.getInputStream()));
String output = null;
while ((output = outStream.readLine()) != null){
System.out.println(output);}outStream.close();
} catch (IOException e) {
e.printStackTrace();
}
So the problem is the exceptions. In the current state, the program gives me:
Quote:
Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem:
Unhandled exception type InterruptedException
at Convert.actionPerformed(Convert.java:112)
at javax.swing.AbstractButton.fireActionPerformed(Unk nown Source)...
I know the problem originates from the p.waitFor() line, I'm not even sure if I really need it. Every example code I have read for a simple process/runtime program has similar code, except some of them catch Exceptions in general, and some catch IOExceptions.
Anybody have any idea where I can start looking to understand the problem?