(我不确定这是否是问这个问题的正确地点。请移至合适的站点)
我有以下代码所示的问题。它在装有CITRIX Xen App 6-的计算机(Windows 2008)上不起作用。没有错误,只是没有启动浏览器。在我的桌面(Windows7框)上,它可以工作。
package trials;
import java.awt.*;
import java.io.File;
import java.io.IOException;
public class Launch {
public static void main(String[] args) throws IOException {
if (args.length < 1) {
System.out.println("argument filepath expected");
return;
}
final boolean browseSupported = Desktop.getDesktop().isSupported(Desktop.Action.BROWSE);
if ( !browseSupported) {
System.out.println("Browse not supported");
return;
}
final String filename = args[0];
final File file = new File(filename);
if (file.exists()) {
Desktop.getDesktop().browse(file.toURI());
} else {
System.out.println(file.getAbsolutePath() + " does not exist");
}
}
}
我尝试按照以下答案中的建议使用“打开”。它不起作用。问题缩小到Java的64位版本(Oracle 1.6.0_25)
我认为导致此症状的原因是awt软件包使用了win2008不支持的系统调用。但这是一个提示。
我认为您应该为此尝试其他解决方案:
if (file.exists()) {
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + file.toURI());
} else {
System.out.println(file.getAbsolutePath() + " does not exist");
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句