this is my code, its meant to play an mp3 file which I put in my bluej folder, im really stumped with the toolbox error though.
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import java.io.File;
import java.net.URI;
import java.net.URL;
public class JavaAudioPlaySoundExample2
{
public static void main(String[] args) {
try {
System.out.print("pls work");
String bip = "Mattashi8bit.mp3";
Media hit = new Media(new File(bip).toURI().toURL().toString());
MediaPlayer mediaPlayer = new MediaPlayer(hit);
mediaPlayer.play();
} catch (Exception e) {
}
}
}
this is the full error
Exception in thread "Thread-29" java.lang.IllegalStateException: Toolkit not initialized
at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:273)
at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:268)
at javafx.application.Platform.runLater(Platform.java:83)
at javafx.scene.media.Media$_MetadataListener.onMetadata(Media.java:541)
at com.sun.media.jfxmediaimpl.MetadataParserImpl.done(MetadataParserImpl.java:120)
at com.sun.media.jfxmediaimpl.platform.java.ID3MetadataParser.parse(ID3MetadataParser.java:237)
at com.sun.media.jfxmediaimpl.MetadataParserImpl.run(MetadataParserImpl.java:103)
I would be really grateful if someone could fix me how to fix the code