How can I run an external file in Java? Like opening a batch or a PDF file?
I want to add it to a jButton with Netbeans, so if somebody pushs on it, it will launch this file from a specified directory
Theres not a lot about this to find on the internet (except a web application, but it needs to be a file/batch/.exe ....
AS SAID its for Netbeans! Everytime I use those commands inside a Button Class:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("msg * hello");
}
I get an error for the line:
Process pr = rt.exec("msg * hello");
Which says:
unreported exception IOException; must be caught or declared to be thrown
Now how do I launch an external file?