Desktop.getDesktop().browse挂起 [英] Desktop.getDesktop().browse Hangs

查看:615
本文介绍了Desktop.getDesktop().browse挂起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,如果用户单击链接,我希望该链接在其默认浏览器中打开.从我读过的内容来看,从理论上讲应该可以,但是,当在Linux(特别是Linux Mint 17.1)上运行时,它会挂起,直到程序被强制退出为止.我对在WebView中打开它并不特别感兴趣.大家能想到的替代方案或修补程序吗?预先感谢.

I'm working on an application in which if a user clicks on a link, I want it to open in their default browser. From what I've read, this should in theory work, however, when run on Linux (specifically Linux Mint 17.1), it hangs until the program is force-quit. I'm not particularly interested in having it open in WebView. Any alternatives or fixes that you all can think of? Thanks in advance.

if(Desktop.isDesktopSupported()){
    try{
       Desktop.getDesktop().browse(new URI(url));
    }catch (IOException | URISyntaxException e){
       log.debug(e);
    }
}

推荐答案

You are not alone. This is a bug that appears to happen in some versions of JDK 1.6 and 1.7. I haven't seen it occuring in JDK 1.8.

它也可能在Windows上发生,您所能做的就是更新JVM或不使用Desktop类(很糟糕).

It can occur on Windows too and all you can do is either update the JVM or not use the Desktop class (which sucks).

这篇关于Desktop.getDesktop().browse挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆