title: Playing sound with AudioClip in Java - JackRouter error?
body: <p>I'm relatively new to Java, though now I'm delving a little bit further in here.</p>
  
  <p>I'm creating a program that displays a button of a chicken, and upon clicking this button, an audioclip of the chicken clucking is played. Simple, it seems, yet I really can't get audio to work at all.</p>
  
  <p>I'm using AudioClip to try to accomplish this. The book that I've been using to teach myself, [i]Introduction to Java Programming[/i] (eighth edition) by Y. Daniel Liang, tells me that I can use AudioClip despite in a non-Applet program despite its location. </p>
  
  <p>I'm having trouble getting this to work, though, so here's what I have so far. I'll give you my code and then give you the error I'm receiving.</p>
  
  <p>I'm temporarily on a Mac, by the way, and haven't had a chance to try it on Windows. Don't know why that would affect anything, but there you go.</p>
  
  <pre><code>//this is the class that plays the sound. The main class follows.
  
  import javax.swing.JApplet;
  import java.applet.*;
  import java.net.URL;
  
  
  public class ChickenSound extends JApplet
  {
  private AudioClip chSound; //creates AudioClip
  
  public ChickenSound()
  {
      URL url = getClass().getResource("resources/chicken-sound.wav"); //creates a url that is the path of the soundfile
      chSound = this.newAudioClip(url); //sets AudioClip equal to the url
      chSound.play(); //plays AudioClip
  }
  }
  
  
  //main class
  // some of these imports are unnecessary but I will clean them up later
  import java.applet.*;
  import java.awt.*;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.net.*;
  
  import java.net.URL;
  import javax.swing.*;
  
  
  public class ChickenButton extends JFrame
  {
  private ImageIcon chBtnIcon = new ImageIcon("resources/chicken-side.png");
  private JButton chBtn = new JButton(chBtnIcon);
  private JPanel panel = new JPanel(new GridBagLayout());
  
  public ChickenButton() //main window
  {
      GridBagConstraints c = new GridBagConstraints();
  
      chBtn.setBorder(BorderFactory.createEmptyBorder());
      chBtn.setContentAreaFilled(false);
      Font bigFont = new Font("Times New Roman", Font.BOLD, 25);
      JLabel chLbl = new JLabel("Click the Chick'n");
      chLbl.setFont(bigFont);
  
  
      c.gridheight = 1;
      c.gridx= 0;
      c.gridy = 0;
      c.weighty = 2;
      panel.add(chLbl,c);
      c.gridheight=2;
      c.gridx= 0;
      c.gridy = 1;
      c.weighty = 2;
      panel.add(chBtn, c);
      add(panel);
  
      chBtn.addActionListener(new ChLstnr()); //creates click listener for button
  }
  
  public static void main(String[] args)
  {
      ChickenButton window = new ChickenButton();
      window.setLocationRelativeTo(null);
      window.setTitle("Chick'n Button");
      window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      window.setSize(300, 400);
      window.setVisible(true); //creates window
  
  }
  
  class ChLstnr implements ActionListener
  {   
      public void actionPerformed(ActionEvent e) 
      {
          System.out.println("Cluck cluck cluck"); //for button functionality testing purposes (and it works)
          ChickenSound chSnd = new ChickenSound(); //this is supposed to play the sound. This doesn't work.
      }   
  }
  
  }
  </code></pre>
  
  <p>The errors I receive are...</p>
  
  <pre><code>2012-07-06 15:44:33.365 java[41264:ff03] Error loading /Library/Audio/Plug-Ins/HAL/JackRouter.plugin/Contents/MacOS/JackRouter:  dlopen(/Library/Audio/Plug-Ins/HAL/JackRouter.plugin/Contents/MacOS/JackRouter, 262): no suitable image found.  Did find:/Library/Audio/Plug-Ins/HAL/JackRouter.plugin/Contents/MacOS/JackRouter: no matching architecture in universal wrapper
  
  
  2012-07-06 15:44:33.367 java[41264:ff03] Cannot find function pointer New_JackRouterPlugIn for factory 7CB18864-927D-48B5-904C-CCFBCFBC7ADD in CFBundle/CFPlugIn 0x102191490 &lt;/Library/Audio/Plug-Ins/HAL/JackRouter.plugin&gt; (bundle, not loaded)
  </code></pre>
  
  <p>I really have no idea what this means. Obviously it has something to do with an audio plug-in that can't be loaded, but I don't really know. From what it seems this may be more of an error with my computer than something I'm messing up with Java, but I've found no solution so far. I've tried this with two IDEs, Eclipse and Netbeans, and they both produce the same errors. Does anyone have an idea what's up with this?</p>
  
  <p>Any help is greatly appreciated.</p>
  
  <p>Thanks.</p>
  
  <p>Edit:
  It just works now. Somehow.</p>