Java的 - Desktop.getDesktop()浏览(URI)的支持,但不打开文档(思杰问题吗?)但不、文档、问题、Desktop

由网友(對不起丶妳沒有訪問權限)分享简介:(我不知道这是否是问这个问题的正确位置,请移动到合适的位置)(I am not sure if this is the correct place to ask this question. Please move to suitable site)我有显示,在下面code的一个问题。它不上机(视窗2008),其具...

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

(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");
    }
阅读全文

相关推荐

最新文章