Hello, this code is throwing and IOException and FileNotFoundException and I am having trouble figuring out why. Where exactly does the song need to go in order for the program to pick it up? Also, is this code for putting the song in the program correct?
Thanks!

//Hangman a game where you test your word-guessing skills against the worlds smartest computer simulation.
 
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import sun.audio.AudioPlayer;
import sun.audio.AudioStream;
import sun.audio.AudioData;
import java.util.Random;
import java.util.Locale;
import java.text.*;
import javax.swing.plaf.metal.*;
 
 
public class hangman {
     public static void main(String[] args)
    {
        
        EventQueue.invokeLater(
                new Runnable()
                {
                    public void run()
                    {
                        hangmanframe frame = new hangmanframe();
                        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                        frame.setVisible(true);
                       try{
                         UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
 
                        }
                        catch (ClassNotFoundException e) {
                        }
           
            catch (UnsupportedLookAndFeelException e) {
 
            }
           
            catch (Exception e) {
   
            }  
 

                 }
                });
    }
   
}
    class hangmanframe extends JFrame
    {
        public hangmanframe()
        {
            this.setSize(1282, 772);
            this.setTitle("Hangman");
           
            JMenuBar greenMenuBar = new JMenuBar();
            greenMenuBar.setOpaque(true);
            greenMenuBar.setBackground(new Color(154, 165, 127));
            greenMenuBar.setPreferredSize(new Dimension(200, 20));
            JLabel blueLabel = new JLabel();
            blueLabel.setPreferredSize(new Dimension(200, 180));
            this.setVisible(true);
            this.setJMenuBar(greenMenuBar);
            this.getContentPane().add(blueLabel, BorderLayout.CENTER);
            this.pack();
            GUI panel = new GUI(greenMenuBar);
            this.add(panel);
        }
    }
    class GUI extends JPanel
    {
      public GUI(JMenuBar menu)
      {
          Random generator = new Random();
          NumberFormat moneyFormat = NumberFormat.getCurrencyInstance(Locale.US);
          int generator1;
          generator1 = generator.nextInt(20)+1;
          array = new String[20];
          array[0] = "Fascist";
          array[1] = "Dictator";
          array[2] = "Aligator";
          array[3] = "Watermelon";
          array[4] = "Impinge";
          array[5] = "Strenuous";
          array[6] = "Condescending";
          array[7] = "Allocate";
          array[8] = "Rhetoric";
          array[9] = "Elementary";
          array[10] = "Rocketship";
          array[11] = "Laminate";
          array[12] = "Exuberance";
          array[13] = "Vivacious";
          array[14] = "Dismemberment";
          array[15] = "Pat Sagack";
          array[16] = "Double Money";
          array[17] = "Watergate";
          array[18] = "Utopia";
          array[19] = "Indent";
          int i = 0;
          String lines = "";
          while(i < array[generator1].length())
          {
                lines += "-";
                i++;
          }
          JLabel line = new JLabel(lines);
          JLabel word = new JLabel(array[generator1]);
          JMenu helpMenu = new JMenu("Help");
          JMenuItem instructions = new JMenuItem("Instructions");
          panel = new JPanel(new BorderLayout());
          menu.add(helpMenu);
          helpMenu.add(instructions);
          instructions.addActionListener(new helpButtonAction());
          //JLabel name = new JLabel("hi");
         //panel.add(name, BorderLayout.SOUTH);
 
         JButton hangmanButton = new JButton("Good Day");
         panel.add(hangmanButton, BorderLayout.SOUTH);
         hangmanButton.addActionListener(new guessButtonAction());
         waterfall = new ImageIcon("C:/Program Files/jungle_mountains.jpg");
         this.add(panel);
         repaint();
         panel.add(word, BorderLayout.CENTER);
         panel.add(line, BorderLayout.NORTH);
         this.add(panel);
        
       AudioPlayer myBackgroundPlayer = AudioPlayer.player;
        AudioStream myBackgroundMusic;
        AudioData myData;
    AudioStream myLoop;
        //use a try block in case the file doesnt exist.
        try {
            myBackgroundMusic = new AudioStream(new FileInputStream("youtube - gift of gab - way of the light.wav"));
            myData = myBackgroundMusic.getData();
            //myLoop = new ContinuousAudioDataStream(myData);
           }
        catch(IOException error) {}
 
 //play background music.
       //myBackgroundPlayer.start(myLoop);
 
         repaint();
      }
      public void paintComponent( Graphics g )
        {
            // should be the FIRST line in a paintComponent method,
            //    calling its superclass' version of this method!
            super.paintComponent( g );
            waterfall.paintIcon(panel, g, 0, 0);
       
        } // e
        private class guessButtonAction implements ActionListener
        {
            public void actionPerformed(ActionEvent event)
            {
                JOptionPane.showMessageDialog(null, "Hang Man");
               
            }
        }
        private class helpButtonAction implements ActionListener
        {
           
            public void actionPerformed(ActionEvent event)
                   
            {
           
            panel.remove(hangmanButton);
            JLabel label = new JLabel("Welcome to Hangman; a game that tests your skills, not in a numerical way, but in a alphabetical way. The rules are simple, but can be altered in your brain but the premise of the game is easy. \nYou start off by clicking on the start game button. Then you are transported to a new area in the game, the game-area. One you are there you will guess letters according to how much of the hangman has decreased. On that note every time you guess the wrong letter one body part will be taken away from the hangman.");
            panel.add(label, BorderLayout.EAST);
            JPanel helpPanel = new JPanel();
            helpPanel.setLayout (new BorderLayout());
         
           
            }
        }
       
      ImageIcon waterfall;
      JButton hangmanButton;
      JPanel panel;
      String array[];
    }

Where exactly do you get those exceptions. A FileNotFoundException means exactly that; the file you are trying to access doesn't exist.

it was thrown here: myBackgroundMusic = new AudioStream(new FileInputStream("youtube - gift of gab - way of the light.wav"));
myData = myBackgroundMusic.getData();
myLoop = new ContinuousAudioDataStream(myData);

But the file does exist, but I think maybe I'm not putting it in the right place. Where does it need to be put?
Also, what is an IOException?

it was thrown here: myBackgroundMusic = new AudioStream(new FileInputStream("youtube - gift of gab - way of the light.wav"));
myData = myBackgroundMusic.getData();
myLoop = new ContinuousAudioDataStream(myData);

But the file does exist, but I think maybe I'm not putting it in the right place. Where does it need to be put?
Also, what is an IOException?

IOException -> Input-OutputException.

since I don't know the AudioStream class, and since you don't specify what packages you're using, I don't really know where it's thrown.

Try using the whole path of the file

These are the packages:
sun.audio.AudioPlayer;
sun.audio.AudioStream;
sun.audio.AudioData;

Thanks for your help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.