Table of Contents

Adding Sound to Your Application

Here is a Java method to play a short bell sound effect that is in a wav format.

You will need the file bell.wav

import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
 
public void playBell() 
{
  File bellFile = new File("bell.wav");
  try 
  {
      Clip bell = AudioSystem.getClip();
      bell.open(AudioSystem.getAudioInputStream(bellFile));
      bell.start();
  } catch (Exception e) 
  {
      e.printStackTrace();
  }
 
}

Getting sound effect files to play

Making and Editting your own sounds

I recommend Audacity