Problem with Java 1.6 and Desktop.open()

梦想的初衷 提交于 2020-01-02 03:27:05

问题


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?


回答1:


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.



回答2:


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"});



回答3:


I still have this problem with one of my customers, I'll check what version of windows (As far as I remember He uses windows 7, 64-bits). The file association with pdf is OK (checked that). And he uses the latest java version (checked the updates of java), so still an actual problem as far as I Am concerned.....

However i ran in to this bug report: sun bug report 6764271

There is says it might have something to do with the registration of some of the adobe versions (using READ in stead of OPEN in the windows registry).

Still a shame a bug like this is low on prio and still an open bug (reported in 2008).

I'll check with my customer soon and update my answer here as soon as I got it resolved.



来源:https://stackoverflow.com/questions/84460/problem-with-java-1-6-and-desktop-open

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!