Java had audio support since ages but there was no direct way play mp3 files in java.
Thanks to JavaFx , you can now directly play mp3 files from your program. In this way you can avoid storing .wave audio files which are huge in size.
In your JavaFx project you need to put the following lines of code
String source = new File(“audio.mp3″).toURI().toString();
Media media = null;
media = new Media(source);
MediaPlayer mediaPlayer = new MediaPlayer(media);
Note that this will play audio file from the current working directory. Usually the same directory where the above code file exists or the final executable jar directory. You can confirm the directory using the following code.