Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
支持Java-Desktop.getDesktop().browse(URI),但不打开文档(citrix问题?)_Java_Windows_64 Bit_Citrix_Xenapp - Fatal编程技术网

支持Java-Desktop.getDesktop().browse(URI),但不打开文档(citrix问题?)

支持Java-Desktop.getDesktop().browse(URI),但不打开文档(citrix问题?),java,windows,64-bit,citrix,xenapp,Java,Windows,64 Bit,Citrix,Xenapp,(我不确定这是否是问这个问题的正确地点。请移到合适的地点) 我有一个问题,如下代码所示。它在具有CITRIX Xen App 6-的计算机(windows 2008)上不工作。没有错误,只是浏览器没有启动。在我的桌面上(windows7框),它可以工作 package trials; import java.awt.*; import java.io.File; import java.io.IOException; public class Launch { public st

(我不确定这是否是问这个问题的正确地点。请移到合适的地点)

我有一个问题,如下代码所示。它在具有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.awt.*;
导入java.io.File;
导入java.io.IOException;
公开课启动{
公共静态void main(字符串[]args)引发IOException{
如果(参数长度<1){
System.out.println(“应为参数文件路径”);
返回;
}
final boolean browseSupported=Desktop.getDesktop().isSupported(Desktop.Action.BROWSE);
如果(!browseSupported){
System.out.println(“不支持浏览”);
返回;
}
最终字符串文件名=args[0];
最终文件=新文件(文件名);
if(file.exists()){
Desktop.getDesktop().browse(file.toURI());
}否则{
System.out.println(文件.getAbsolutePath()+“不存在”);
}
}
}

我试着按照下面的回答使用“open”。它不起作用。问题被缩小到64位版本的Java(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");
    }

要打开本地文件,必须使用
Desktop().open()
而不是
Desktop.browse()
Desktop.browse()
启动本地web浏览器。在Windows上,web浏览器可能会将其踢出到默认shell,从而打开文件

我的猜测是Citrix系统上的浏览器无法/没有正确处理该文件,因此无法将其传递给shell


在任何情况下,如果您正在打开一个文件(而不是URL),那么您可能希望使用
Destop.open()

我在Windows XP上测试过的另一种简单的可能性:

org.eclipse.swt.program.Program.launch("file://" + filename);

我在桌面类上也有类似的问题


如果文件无法打开但引发异常,请尝试编辑它。我在一些图像文件和窗口上遇到了问题,因为除了编辑器之外没有关联的程序。

这在非windows系统上不起作用,所以我建议不要使用它。没有找到实际的代码修复程序,我们使用了上面的解决方法,但使用了ProcessBuilder。