java.awt.Desktop.browse 返回“在任何活动的激活上下文中均未找到请求的查找密钥”仅适用于 Win XP

发布于 2024-12-07 09:36:17 字数 1177 浏览 0 评论 0原文

单击按钮时,我使用以下代码从 java 访问默认浏览器:

if( !java.awt.Desktop.isDesktopSupported() ) {
    System.err.println( "Desktop is not supported (fatal)" );
}
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();

if( !desktop.isSupported( java.awt.Desktop.Action.BROWSE ) ) {
    System.err.println( "Desktop doesn't support the browse action (fatal)" );
}

String number = txtInCall.getText();

String uriString = "http://localwebserver/new?number="+number;
//number only contains numbers similar to 023456789
try {
    java.net.URI uri = new java.net.URI( uriString );
    desktop.browse( uri );
}
catch ( Exception ex ) {
    System.err.println( ex.getMessage() );
}

该程序在 Windows 7 Home Premium x64 上运行良好。如果我在 Windows XP Professional x32 SP3 上测试它,控制台将返回:“在任何活动的激活上下文中均未找到请求的查找密钥”。

我用谷歌搜索了一下,发现该错误是与 Internet Explore 有关的。然而,测试机器上的默认浏览器是 Mozilla Firefox 6.0.2。我还检查了注册表,http 协议已为 firefox.exe 注册,并且我更新了 IE。

有关此错误的其他问题 也没有帮助我。在 XP 计算机上,单击总是会返回上述错误。

I use the following code to access the default browser from java when a button is clicked:

if( !java.awt.Desktop.isDesktopSupported() ) {
    System.err.println( "Desktop is not supported (fatal)" );
}
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();

if( !desktop.isSupported( java.awt.Desktop.Action.BROWSE ) ) {
    System.err.println( "Desktop doesn't support the browse action (fatal)" );
}

String number = txtInCall.getText();

String uriString = "http://localwebserver/new?number="+number;
//number only contains numbers similar to 023456789
try {
    java.net.URI uri = new java.net.URI( uriString );
    desktop.browse( uri );
}
catch ( Exception ex ) {
    System.err.println( ex.getMessage() );
}

The programm works well on Windows 7 Home Premium x64. If I test it on Windows XP Professional x32 SP3 the console returns: "The requested lookup key was not found in any active activation context".

I googled about it and found out, that the error occurs in connection with Internet Explore. The default browser on the tested machines howerer is Mozilla Firefox 6.0.2. I also checked the registry and the http-protocol is registered for firefox.exe and I updated IE.

The other question about this error did not help me either. On the XP machine a click always returns the mentioned error.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文