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

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

问题描述

(我不知道这是否是问这个问题的正确位置,请移动到合适的位置)

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

我有显示,在下面code的一个问题。它不上机(视窗2008),其具有CITRIX Xen的应用6-工作。没有错误,只是浏览器不会被启动。在我的桌面(一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");
        }
    }
}

我试图用开放作为答案如下建议。它不起作用。问题是缩小到Java(甲骨文1.6.0_25)的64位版本

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()浏览(URI)的支持,但不打开文档(思杰问题吗?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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