I've been using Destop.open() to launch a .pdf viewer on Windows machines, both Vista and XP, and most of them work just fine. However, on one XP machine the call does not work, simply returning without throwing any exceptions, and the viewer does not launch. On that machine the file association is properly set up as far as I can tell: double-clicking a .pdf works, as does the "start xxx.pdf" command on the command prompt. I'm thinking it must be a Windows configuration issue, but can't put my finger on it.
Has anyone else seen this problem?
This is a known problem with early versions of XP SP2, the ShellExecute function stopped accepting URIs; bring the XP machines patches up to date.
To view the exceptions make sure the Java Console is turned on:
Control Panel->Java Control Panel->Advanced->Java Console.
I couldn't find the answer anywhere but I have two machines with Windows 7 64 bit that fail the Desktop.getDesktop().open(file) with failed to open file or access is denied error on java 6 and java 7.
Windows Explorer is able to open applications based on the filename with extension:
Runtime rt = Runtime.getRuntime();
rt.exec(new String[]{"explorer", "C:\\myfile.pdf"});
rt.exec(new String[]{"explorer", "C:\\myfile.wmv"});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With