Sonntag, 14. November 2010

Open word from java

One easy way to open a certain doc-file from java is here:

public void open(){
Runtime rt= Runtime.getRuntime();
try {
String path="C:/Program Files/Microsoft Office/OFFICE/WINWORD.exe";
String filename="C:/test/myfile.doc";
Process p =rt.exec(path+" "+filename );
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}