问题
I wish to use one of my local sound files to provide background music, but I get this error message:
Caused by: java.lang.UnsatisfiedLinkError: Can't load library: C:\Program Files\Amazon Corretto\jdk1.8.0_232\jre\bin\glib-lite.dll
But my code is as follow:
public class DungeonGUI extends Application {
private Dungeon dungeon;
private Stage stage;
private GridPane root;
private Button attack;
private Button heal;
// private Button checkInventory;
private Button save;
private Text characterHealth;
private Text characterPower;
private Text characterInventory;
private Text monsterHealth;
private Text monsterPower;
private File audioFile = new File("C:/Users/15774/Downloads/oof.mp3");
@Override
public void start(Stage stage) throws Exception {
setButtons();
dungeon = new Dungeon();
setTexts();
this.stage = stage;
root = new GridPane();
heal.setOnAction(this::onHeal);
attack.setOnAction(this::onAttack);
save.setOnAction(this::onSave);
stage.setTitle("Dungeone Dungeon");
root.setAlignment(Pos.CENTER);
setMedia();
setupRoot();
setStage(stage);
}
private void setMedia() {
Media media = new Media(audioFile.toURI().toString());
MediaPlayer mediaPlayer = new MediaPlayer(media);
mediaPlayer.setAutoPlay(true);
}
As you can see I did not call program files at any time. What might be the problem?
P.S.: this is only part of my code. If you guys need more information just shoot a comment.
回答1:
Amazon's Corretto 8
doesn't contain the necessary artifacts for JavaFX support
.
You have to integrate some third party jar/jars that you have to check online.
You can use OpenJFX
which is open source library that provides JavaFX support. OpenJFX is a project of OpenJDK.
It supports from JDK 11 onwards but you can try that with Corretto 8. It may work.
Try to use Oracle's JDK version 8
/ OpenJDK version 8
.
Note : Oracle's JDK 8
supports JavaFX
(it has necessary libraries for JavaFX support). Open JDK version 8 may include OpenJFX (you can check).
Read this :
Is JavaFX media supported by Corretto?
https://github.com/corretto/corretto-8/issues/26
来源:https://stackoverflow.com/questions/60750910/how-to-fix-unsatisfiedlinkerror