title: Using JavaFX's MediaPlayer in an existing Swing Project
body: <p>I have an application written in Swing, in which I want to use JavaFX's MediaPlayer for playing audio / sound files.</p>
  
  <p>This is a condensed version of the main file:</p>
  
  <pre><code>class MyApp
  {
     private MyApp myApp;
     private JFrame myFrame;
     private Media media;
     private MediaPlayer mediaPlayer;
     public static void main(String[] args)
     {
        Runnable thread = new Runnable()
        {
           public void run()
           {
               myApp = new MyApp();
           }          
        };
        SwingUtilities.invokeLater(thread);
    }
    public void MyApp()
    {
      //this is called by SwingUtilities.invokeLater();
  
      URL url = //getting URL to a sound file stored locally//;
      media = new Media(url.toString() );
      mediaPlayer = new MediaPlayer( media );                        
      mediaPlayer.play();
  
      myFrame = new JFrame(); //building swing UI here
    }
  </code></pre>
  
  <p>This seems to work within Netbeans. However when Netbeans builds a .jar, and I try to run the .jar, I get an error log file built in the .jar directory containing some memory / threading errors.</p>
  
  <p>Do I need to use the <code>Platform.runLater()</code> method to get this to work? Or is there anything else I'm doing wrong?</p>