title: How to play sounds with JavaFX
body: <p>I just started working with JavaFX. I know how the basics of it work. I tried to use the media and the mediaplayer classes to play a sound, called "sound.mp3". I am programming in eclipse, and I have the sound file in the src folder, the same folder as "(default package)". Here is my code:</p>
  
  <pre><code>import javafx.scene.media.*;
  import javafx.application.Application;
  import javafx.scene.Scene;
  import javafx.scene.layout.StackPane;
  import javafx.stage.Stage;
  
  public class Main extends Application {
  
      public static void main(String[] args) {
          launch(args);
      }
  
      @Override
      public void start(Stage primaryStage) {
          primaryStage.setTitle("Hello World!");
  
          String ssound = "sound.mp3";
          Media sound = new Media(ssound);
          MediaPlayer mediaPlayer = new MediaPlayer(sound);
          mediaPlayer.play();
  
          StackPane root = new StackPane();
          primaryStage.setScene(new Scene(root, 800, 450));
          primaryStage.show();
      }
  }
  </code></pre>
  
  <p>Please tell me what I'm doing wrong.</p>
  
  <p>Here is the error message thing from the console:</p>
  
  <pre><code>Exception in Application start method
  Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
      at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
      at com.sun.javafx.application.LauncherImpl.access$000(Unknown Source)
      at com.sun.javafx.application.LauncherImpl$1.run(Unknown Source)
      at java.lang.Thread.run(Thread.java:724) Caused by: java.lang.IllegalArgumentException: uri.getScheme() == null!
      at com.sun.media.jfxmedia.locator.Locator.&lt;init&gt;(Unknown Source)
      at javafx.scene.media.Media.&lt;init&gt;(Unknown Source)
      at Main.start(Main.java:16)
      at com.sun.javafx.application.LauncherImpl$5.run(Unknown Source)
      at com.sun.javafx.application.PlatformImpl$5.run(Unknown Source)
      at com.sun.javafx.application.PlatformImpl$4$1.run(Unknown Source)
      at com.sun.javafx.application.PlatformImpl$4$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.sun.javafx.application.PlatformImpl$4.run(Unknown Source)
      at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
      at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
      at com.sun.glass.ui.win.WinApplication.access$100(Unknown Source)
      at com.sun.glass.ui.win.WinApplication$3$1.run(Unknown Source) ... 1 more
  </code></pre>