Java和Mac OS java -jar

问题描述 投票:0回答:1

我创建了一个java应用程序来解析mediainfo库中的电影,在Windows操作系统上它工作得很好,在Mac操作系统上:如果电影是在外部磁盘上,它也工作得很好,但如果电影是在 "HD MAC"(例如在桌面或下载文件夹中),它就不能工作。在Windows操作系统上,它工作得很好.在Mac操作系统上:如果电影是在外部磁盘上,它也工作得很好,但如果电影是在 "HD MAC"(例如在桌面或下载文件夹),它不工作。

现在如果我用终端命令启动我的应用程序 java -jar <myApp.jar> 所有的工作,无论电影存储在哪里。java -jar <myApp.jar> 并双击.jar启动应用程序?

谢谢。

如果我用java -jar启动,我就会出现以下错误

Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: java.nio.ByteBuffer.clear()Ljava/nio/ByteBuffer;
        at addon.TorrentProcessor.generatePieceHashes(TorrentProcessor.java:361)
        at addon.TorrentProcessor.generatePieceHashes(TorrentProcessor.java:375)

就是这句话

public void generatePieceHashes(TorrentFile torr) {
        ByteBuffer bb = ByteBuffer.allocate(torr.pieceLength);
        int index = 0;
        long total = 0;
        torr.piece_hash_values_as_binary.clear();
        for (int i = 0; i < torr.name.size(); i++) {
            total += (Integer) torr.length.get(i);//
            File f = new File((String) torr.name.get(i));
            if (f.exists()) {
                try {
                    FileInputStream fis = new FileInputStream(f);
                    int read = 0;
                    byte[] data = new byte[torr.pieceLength];
                    while ((read = fis.read(data, 0, bb.remaining())) != -1) {
                        bb.put(data, 0, read);
                        if (bb.remaining() == 0) {
                            torr.piece_hash_values_as_binary.add(Utils.hash(bb.
                                    array()));
                            bb.clear(); // the error is here
                        }
                    }
                } catch (FileNotFoundException fnfe) {} catch (IOException ioe) {}
            }
        }
        if (bb.remaining() != bb.capacity())
            torr.piece_hash_values_as_binary.add(Utils.hash(Utils.subArray(
                    bb.array(), 0, bb.capacity() - bb.remaining())));
    }

否则,如果我用双击启动,就不会出错。?

java macos terminal
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.