Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

How do I fix this error?

import java.awt.*;

import hsa.Console;

import java.io.IOException;

import javax.sound.sampled.AudioInputStream;

import javax.sound.sampled.AudioSystem;

import javax.sound.sampled.AudioFormat;

import javax.sound.sampled.spi.AudioFileReader;

import javax.sound.sampled.UnsupportedAudioFileException;

import javax.sound.sampled.LineUnavailableException;

public class Sound

{

static Console c; // The output console

public static void main (String[] args)

{

c = new Console ();

sound ();

} // main method

public static void sound ()

{

try

{

AudioInputStream audio;

audio = AudioSystem.getAudioInputStream (this.getClass ().getResource ("Deal Or No Deal Full Theme Song.wav"));

javax.sound.sampled.Clip clip = AudioSystem.getAudioInputStream (java.io.File $1);

clip.open (audio);

clip.start ();

}

catch (UnsupportedAudioFileException uae)

{

}

catch (IOException ioe)

{

}

catch (LineUnavailableException lua)

{

}

}

---------------------------------------------------------

I am working with Ready To Program with Java. I am using HSA consoles. Everything seems to be working except one line:

javax.sound.sampled.Clip clip = AudioSystem.getAudioInputStream (java.io.File $1);

where the program is giving me an error with "$1" (it is highlighting only the "$1"). There are no other errors in the program. I am trying to get sound to play when I run the program.

1 Answer

Relevance
  • david
    Lv 7
    7 years ago
    Favorite Answer

    um... what is $1 supposed to be? The program is expecting a file there. Which file is $1, and where is that defined?

Still have questions? Get your answers by asking now.