Java无法加载URI

Java无法加载URI,java,swing,uri,Java,Swing,Uri,我正在尝试添加到JLabel的链接。我已将以下侦听器添加到我的JLabel中: mouseAdapter = new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() > 0) { if (Desktop.isDesktopSupported()) {

我正在尝试添加到JLabel的链接。我已将以下侦听器添加到我的JLabel中:

   mouseAdapter = new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() > 0) {
                    if (Desktop.isDesktopSupported()) {
                        Desktop desktop = Desktop.getDesktop();
                        try {
                            URI uri = new URI(path);
                            desktop.browse(uri);
                        } catch (Exception ex) {
                            LOGGER.error("Erorr when diplaying link for reports " + ex.getMessage());
                            JOptionPane.showMessageDialog(jpanel, "Eroare la afisarea raportului detaliat", "error",
                                    JOptionPane.ERROR_MESSAGE);
                        }
                    }
                }
            }
        };
        detailsLabel.addMouseListener(mouseAdapter);
但单击标签时,会记录以下错误:

 Failed to show URI:/home/luci/workspace/LabMetrics/operations/target/detailedReport.html

我必须提到,路径是一个有效的html页面。我使用的是Ubuntu14.04,我安装了libgnome2.0-cil-dev,但它仍然不起作用

我在路径之前添加了file://文件,它可以正常工作。非常感谢

我认为您的URI中没有协议。有效的uri如下所示:protocol://path. 因此,您可能必须在URI前面添加file://或http://文件。