Reputation: 19
I'm new to java and I'm trying to make my javafx application play a sound. I'm not being able though to create a javafx.scene.media.Media object as I keep getting the exception.
java.lang.UnsatisfiedLinkError: Can't load library: C:\Users\Cliente\.jdks\corretto-1.8.0_252\jre\bin\glib-lite.dll
Here is the piece of code that is generating this error.
Media sound = new Media(new File("./data/audio/Bomb.mp3").toURI().toString());
I imagine that this is being generated by my uri being wrongly formatted but I can't see why this is different from tutorials I've seen. My audio file finds itself in /data/audio which is inside the root folder of the project. Can anyone help me?
Upvotes: 1
Views: 3671
Reputation: 53441
I think your problem has nothing to do with the creation of the Media
object.
Amazon Corretto for Java 8 does not support JavaFX. Please, see the following Github issue and this comment:
Hi. The build of OpenJFX 8 in Corretto 8 is currently on life support and we only plan to apply security patches and critical fixes. Upstream, OpenJFX 8 is abandoned (see https://hg.openjdk.java.net/openjfx).
The recommended way of using JavaFX is with Corretto 11 and pulling in OpenJFX separately e.g. with a Maven dependency. The latest version (currently 14) is compatible with Corretto 11.
Closing this issue.
Please, follow the suggested approach, or use a different Java distribution instead.
Please, see also this 1 2 SO questions, I hope they will be help.
Upvotes: 4
Reputation: 1064
Media sound = new Media(new File("./data/audio/Bomb.mp3").toURI().toString());
^ issue.
use
Media sound = new Media(new File("./data/audio/Bomb.mp3").toURI().getPath());
Upvotes: 2