java.awt.Desktop.browse 返回“在任何活动的激活上下文中均未找到请求的查找密钥”仅适用于 Win XP
单击按钮时,我使用以下代码从 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。
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论