Java - Desktop.getDesktop().browse(URI) is supported, but does not open document (a citrix problem?)

核能气质少年 提交于 2019-11-28 01:22:06

I think the cause of this symptom is the awt package what uses a system call what the win2008 not supports. But it's a tip.

I think You should try an other solution for this:

if (file.exists()) {
        Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + file.toURI());
    } else {
        System.out.println(file.getAbsolutePath() + " does not exist");
    }

Another easy possibility that I have tested on Windows XP:

org.eclipse.swt.program.Program.launch("file://" + filename);

To open a local file you have to use Desktop().open() not Desktop.browse()

Desktop.browse() launches the local web browser. On Windows, the web browser is probably kicking it out to the default shell, which opens the file.

My guess is that the browser on the Citrix system cannot/doesn't handle the file properly, thus not passing it to the shell.

In any case, it appears that if you are opening a file (and not a URL), then you want to use Destop.open() instead.

I had a similar problem with the Desktop-class.

If the file will not open but throws an exception, try to edit it. I had trouble with some image files and windows, because there was no associated program but an editor.

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