Api Desktop.isDesktopSupported在windows中返回null
我有以下代码Api Desktop.isDesktopSupported在windows中返回null,api,desktop,Api,Desktop,我有以下代码 desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null; url = new URL("http://www.facebook.com"); if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) { try { desktop.browse(u
desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
url = new URL("http://www.facebook.com");
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
try {
desktop.browse(url.toURI());
} catch (Exception e) {
e.printStackTrace();
}
Windows 7的桌面正在返回null。有人能建议怎么做吗?来自:
测试当前平台是否支持此类。如果支持,请使用getDesktop()检索实例
返回:
true
如果当前平台支持该类<代码>错误否则
简而言之:
Windows 7不支持此类
- 另见:
- 另见:
Runtime.getRuntime().exec( "rundll32 url.dll,FileProtocolHandler " + url);
可以找到一个非常好的完全工作的代码,它也涵盖了OSX和Linux对不起,我不知道这个问题的解决方法
Runtime.getRuntime().exec( "rundll32 url.dll,FileProtocolHandler " + url);