Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Runtime.exec() command to open default pdf reader

843798Mar 21 2005 — edited Oct 4 2005
Hello
I want to launch a pdf-file (from within the code) on the system default pdf-reader. Can I somehow retrieve the path to the default pdf-reader and use it like this:

String pdfReaderPath = retrievePDFreaderpath(); // ????
String filename = new String("E:\\Test.pdf");
String[ ] open = {pdfReaderPath , filename};

try {
Process proc = Runtime.getRuntime().exec(filename);
} catch (IOException e) {
e.printStackTrace();
}

Thank you!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 20 2005
Added on Mar 21 2005
8 comments
559 views