File as a executable jar file - sound / pictures don't work with gui button(s)
<p>Yes I have researched online stackflow I believe was one place.  And they have questions that "sound / audio" and i believe also "pictures" dont play from executable jar file.  </p>

<p>The wav files are in the jar file...i used winrar to check.  </p>

<p>I ran from the command prompt,  and the sound wouldnt play. And one of the errors that was given was that : </p>

<p>java.io.FileNotFoundException : C:\Users\Bijan\Desktop\Sounds\SexySounds1.wav (The system can not find the path specified) </p>

<p>etc...I have another thing to add.  That the pictures actually do work on the button when only pictures are used from executable jar file,  but audio doesn't seem to play when I try to use a button that implements audio (wav) files.</p>

<p>This code below sets opt for JOptionPane,  and I just put the images inside that box,  and the audio (wav) files. This below code is for the button "Relax" for the gui program.</p>

<pre><code>JButton btnNewButton_1 = new JButton("Relax");
        btnNewButton_1.addActionListener(new ActionListener() {
            private int counter = 0;
            public void actionPerformed(ActionEvent e) {

                  String soundName1 = "Sounds/SexySounds1.wav";
                  String soundName1a = "Sounds/SexySounds2a.wav";
                  String soundName2 = "Sounds/HoShit.wav";
                  String soundName3 = "Sounds/SexySounds2.wav";
                  AudioInputStream audioInputStream = null;

                  JOptionPane opt = new JOptionPane(""); 
                  opt.setPreferredSize(new Dimension(210, 325));
                  final JDialog dialogBoxTitle = opt.createDialog("Sexy Woman");
                  try{
                  if(counter == 0){


                      Image pic = new ImageIcon(this.getClass().getResource("/SexyWoman.png")).getImage();
                      opt.setIcon(new ImageIcon(pic));
                      audioInputStream = AudioSystem.getAudioInputStream(new File(soundName1).getAbsoluteFile());


                  }
                  if(counter == 1){
                      Image pic = new ImageIcon(this.getClass().getResource("/Sexy Woman #2.jpeg")).getImage();
                        opt.setIcon(new ImageIcon(pic));
                        audioInputStream = AudioSystem.getAudioInputStream(new File(soundName2).getAbsoluteFile());
                        try {
                            Thread.sleep(500L);


                        } catch (InterruptedException e1) {

                            e1.printStackTrace();
                        }
                      }
                  if(counter == 2){
                      Image pic = new ImageIcon(this.getClass().getResource("/SexyWoman#3.jpeg")).getImage();
                        opt.setIcon(new ImageIcon(pic));
                        audioInputStream = AudioSystem.getAudioInputStream(new File(soundName1a).getAbsoluteFile());

                      }
                  if(counter == 3){
                      Image pic = new ImageIcon(this.getClass().getResource("/SexyWoman#4.jpeg")).getImage();
                        opt.setIcon(new ImageIcon(pic));
                        audioInputStream = AudioSystem.getAudioInputStream(new File(soundName3).getAbsoluteFile());

                      }
                  if(counter == 4){
                      Image pic = new ImageIcon(this.getClass().getResource("/Bijan's Picture.png")).getImage();
                        opt.setIcon(new ImageIcon(pic));
                      }} catch (UnsupportedAudioFileException e1) {

                            e1.printStackTrace();
                        } catch (IOException e1) {

                            e1.printStackTrace();
                        }
                        Clip clip = null;
                        try {
                            clip = AudioSystem.getClip();
                        } catch (LineUnavailableException e1) {

                            e1.printStackTrace();
                        }
                        try {
                            clip.open(audioInputStream);
                        } catch (LineUnavailableException e1) {

                            e1.printStackTrace();
                        } catch (IOException e1) {

                            e1.printStackTrace();
                        }
                        clip.start();
                        counter++;
                  new Thread(new Runnable()
                        {
                          public void run()
                          {
                            try{


                              Thread.sleep(1500);

                              }catch (InterruptedException e) {

                                e.printStackTrace();
                            }}}).start();
                                dialogBoxTitle.setVisible(true);

            }

            }
        );
</code></pre>

<p>Bijan</p>

<p>PS : I wanted to truly see if the wav files were in the jar file,  and when I run the command prompt :
java -jar "SuperMathBattler1a.jar"  the program runs.  Yet when I try to view contents of the jar file  using :</p>

<p>jar tf SuperMathBattler1a.jar</p>

<p>Then it gives this error : </p>

<p>'jar' is not recognized as an internal or external command, operable program or batch file.</p>

<p>I researched and what was written was that I have to alter the "PATH"  yet that doesnt make sense since when I run it it works,  so the path should be correct right?  There maybe is something really fu--ed with this computer.  I run from command prompt with :</p>

<p>C:\Users\Bijan\Desktop> </p>

<p>and I enter jar tf filename.jar</p>

<p>jar file is in desktop folder,  yet doesnt view contents of jar file,  yet runs it when I input --- java -jar "filename.jar"  </p>