Java - Desktop.getDesktop().browse(URI) 受支持,但不打开文档(citrix 问题?) [英] Java - Desktop.getDesktop().browse(URI) is supported, but does not open document (a citrix problem?)

查看:14
本文介绍了Java - Desktop.getDesktop().browse(URI) 受支持,但不打开文档(citrix 问题?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(我不确定这是否是提出此问题的正确位置.请移至合适的站点)

(I am not sure if this is the correct place to ask this question. Please move to suitable site)

我有一个问题,显示在下面的代码中.它不适用于装有 CITRIX Xen App 6- 的机器(windows 2008).没有错误,只是浏览器没有启动.在我的桌面(一个 windows7 盒子)上,它可以工作.

I have a problem that is shown in below code. It does not work on machine (windows 2008) that has CITRIX Xen App 6-. There is no error, just that browser does not get launched. On my desktop (a windows7 box), it works.

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");
        }
    }
}

我尝试按照以下答案中的建议使用打开".这没用.问题缩小到 64 位版本的 Java(Oracle 1.6.0_25)

I tried to use "open" as suggested in following answers. It did not work. The problem is narrowed down to 64bit version of Java(Oracle 1.6.0_25)

推荐答案

我认为造成这种现象的原因是awt包使用了win2008不支持的系统调用.但这是一个提示.

I think the cause of this symptom is the awt package what uses a system call what the win2008 not supports. But it's a tip.

我认为您应该为此尝试其他解决方案:

I think You should try an other solution for this:

if (file.exists()) {
        Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + file.toURI());
    } else {
        System.out.println(file.getAbsolutePath() + " does not exist");
    }

这篇关于Java - Desktop.getDesktop().browse(URI) 受支持,但不打开文档(citrix 问题?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆