These are the following ways in which you play a sound in Java.
Toolkit - If you just want a beep or quick alert you can use beep() finction of class java.awt.Toolkit. It Emits an audio beep.
AudioClip - The AudioClip interface is a simple abstraction for playing a sound clip.
Clip - The Java Sound API provides functionality for the capture, processing, and playback of sampled audio data & the sequencing and synthesis of MIDI data.
MIDI Sequences - The javax.sound.midi package provides an interfaces and classes for I/O, sequencing, and synthesis of MIDI (Musical Instrument Digital Interface) data.
Please see the sample code of each type
Toolkit - If you just want a beep or quick alert you can use beep() finction of class java.awt.Toolkit. It Emits an audio beep.
AudioClip - The AudioClip interface is a simple abstraction for playing a sound clip.
Clip - The Java Sound API provides functionality for the capture, processing, and playback of sampled audio data & the sequencing and synthesis of MIDI data.
MIDI Sequences - The javax.sound.midi package provides an interfaces and classes for I/O, sequencing, and synthesis of MIDI (Musical Instrument Digital Interface) data.
Please see the sample code of each type