Improve your programs with practical audio

Learn 3 ways to produce sound in Java applications and applets -- and how to grab sounds from JAR files

1 2 Page 2
Page 2 of 2

Advanced sound and other alternatives

At the time of this writing, Sun announced other alternatives for producing sound in a Java program. At the high end, the Java Media Frameworks (JMF) provide a user-extensible framework for transporting and playing sound and video in a Java program. Although this flexible alternative has been implemented for many platforms, JMF is a Java extension and cannot be guaranteed to be available on all Java platforms. The package is quite large and has dependencies on a native implementation.

Sun also announced for Java 1.2 the Java Sound engine, which is implemented with the existing public sound APIs from JDK 1.02 and 1.1. The benefit of this new engine is its ability to play a wider variety of sound types, including WAV, MIDI, RMF, AIFF, and more AU sound formats. At JavaOne '98, Sun announced a public specification for interfacing with the sound engine. This public Java Sound API allows user inspection and manipulation of the sound data.


In this article I have demonstrated several alternative ways to play sound in a Java applet or application, and have shown how simple it is to play sounds in a Java program. I also have shown how to package and extract sounds from developer- or user-provided "sound-scheme" files. Sounds are easy to package in JAR files using published names, ordinal positions, or naming conventions. You can offer users a lot of options for customizing their environments to make them sound just right (from the individual user perspective). As is clear from the Sun announcements, Sun will offer additional and more flexible alternatives in the future. For now, however, these examples show several current options for programmers that want to include sound in their Java programs today.

Dan Becker works in the Network Computing Software Division of IBM Corp. in Austin, TX. He is currently working on Java 1.2 and other Java extensions for IBM Operating System/2. Before that Dan worked on porting previous Java virtual machines, the multimedia plug-ins for Netscape Navigator for OS/2, OpenDoc, and the Multimedia parts for OS/2 Warp Version 4.0. Dan can be reached at his public Webpage at

Learn more about this topic

  • Sun's Java Media API page shows all media-related developments in Java related to playing sound and video
  • Sun's Java Media Frameworks Java Extension page shows an advanced extension to Java that allows playing many sound and video formats
  • Sun's Java Sound API for Java 1.2 page shows upcoming changes to Java 1.2 that allow playing, mixing, and editing many sound formats
  • Sun's Java Tutorials page contains a tutorial on playing Java sounds, as well as other tutorials
1 2 Page 2
Page 2 of 2