Différence entre double click et java -jar pour lancer un jar
Bonjour,
Quelle est (ou sont) la(les) différence(s) entre faire java -jar path_monApp.jar et double click sur le .jar.
quand dans cmd je tape java -jar mon app se lance mais quand je clique sur un bouton de mon app j'ai cette erreur :
Code:
1 2 3
| 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) |
voici les lignes en question
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| 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(); // L erreur est ici
}
}
} 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())));
} |
alors que lorsque je double clique sur mon app et qu'ensuite je clique sur le bouton je n'ai aucune erreur.
Différence entre la commande java -jar myapp.jar et la commande
C:\Program Files>Java\jdk-14.0.1\bin\java -jar myapp.jar