Open a file with an external application on Java [duplicate]
问题 This question already has answers here : How to open a file with the default associated program (3 answers) Closed 3 years ago . How do you open a file from a java application when you do not know which application the file is associated with. Also, because I'm using Java, I'd prefer a platform independent solution. 回答1: With JDK1.6, the java.awt.Desktop class can be useful. public static void open(File document) throws IOException { Desktop dt = Desktop.getDesktop(); dt.open(document); } 回答2