Java Debian 上的应用程序打开和播放媒体错误

Java application open and play media error on Debian

我目前正在开发一个应用程序,我用 Java 编写了它。它正在将一些媒体文件下载到本地计算机并使用名为 Desktop.getDesktop().open(file); 的 Java 方法打开它。它在 windows 上运行良好,但在 debian 上无法运行。 这里使用的是从url下载的方法:

            public String DownloadFromUrlAndGetPath(String DownloadUrl) {
            String fileName="";
            try {
            URL url = new URL(DownloadUrl);
            URLConnection ucon = url.openConnection();
            String raw = ucon.getHeaderField("Content-Disposition");
            // raw = "attachment; filename=abc.mp3"
            if(raw != null && raw.indexOf("=") != -1) {
                fileName = raw.split("=")[1]; //getting value after '='
                fileName = fileName.replace("\"", "").trim();
            } else {
                return "";
            }
            File file = new File(Paths.get(System.getProperty("user.home"), "MyFolderToSaveFiles") +"/"+ fileName);


                InputStream is = ucon.getInputStream();
                BufferedInputStream bis = new BufferedInputStream(is);
                ByteArrayBuffer baf = new ByteArrayBuffer(5000);
                int current = 0;
                while ((current = bis.read()) != -1) {
                    try {
                        baf.append((int)((byte)current));
                        continue;
                    }
                    catch (Exception var12_13) {

                    }
                }
                FileOutputStream fos = new FileOutputStream(file);
                fos.write(baf.toByteArray());
                fos.flush();
                fos.close();

        }
        catch (IOException e) {
            e.getMessage();
        }
    }
    return Paths.get(System.getProperty("user.home"), "MyFolderToSaveFiles") +"/"+ fileName;

然后我想像这样打开那个文件:

File f = new File(url);
Desktop.getDesktop().open(f);

错误说;

有什么建议吗?谢谢

我使用 this 解决了这个问题,所以当我打开文件时,我使用的是 xdg-open..