Java Media Framework
| Company type | Software library |
|---|---|
| Industry | Multimedia software |
| Founded | 1997 |
| Founder | Sun Microsystems, Silicon Graphics, Intel |
Area served | Cross-platform (Java SE) |
| Products | Multimedia framework for Java applications and applets |
| Owner | Sun Microsystems (original), later Oracle Corporation |
The Java Media Framework (JMF) is a Java library designed to facilitate the integration of audio, video, and other time-sensitive media within Java applications and applets. This optional extension enables functionalities such as capturing, playback, streaming, and transcoding across various media formats, thereby augmenting the capabilities of the Java Platform, Standard Edition (Java SE) for developing multimedia software that operates across platforms.
Versions and licensing
The initial release, JMF 1.0, launched in 1997 through a collaboration between Sun Microsystems, Silicon Graphics, and Intel, provided playback-only features. Subsequently, in 1999, Sun and IBM introduced JMF 2.0, which expanded support to include media capture, streaming features, pluggable codecs, and transcoding capabilities. As part of Sun’s "Desktop" technology suite for J2SE, JMF is accessible from both Java applets and Java Web Start applications via the underlying Java Runtime Environment (JRE).
At its inception, JMF 2.0 incorporated both an MP3 decoder and encoder; however, the encoding component was removed in 2002, with a playback-only MP3 plug-in added later in 2004.
JMF’s binary distributions are governed by a proprietary license, while its source code is made available under the terms of the SCSL.
The latest package comprises four JAR files along with shell scripts to launch various JMF utilities:
- JMStudio – a straightforward graphical media player
- JMFRegistry – a tool for managing preferences and plugins
- JMFCustomizer – generates streamlined JAR files containing only the necessary classes tailored for specific applications
- JMFInit
JMF is offered either as a pure Java implementation or through platform-specific "performance packs" that integrate native-code media players and engines for Linux, Solaris (SPARC), and Windows environments.
In 2011, Tudor Holton from the Bentokit Project created Debian packages aimed at simplifying JMF installation on Debian and Ubuntu Linux systems by automating license acceptance and Oracle downloads. A similar installer was also developed for the JMF MP3 Plugin.
Design concepts
Within JMF’s architecture, media is represented abstractly as DataSource objects for input streams and DataSink objects for output destinations. The framework restricts developers from directly manipulating format specifics; instead, media is treated as sources—often URLs—that can be played back, processed, or exported. However, transcoding support varies depending on codec availability.
Applications interact with JMF primarily via the Manager class, which offers static methods serving as the core interface to the framework’s functionality.
Criticism and alternatives
The codecs and formats supported by JMF in contemporary Java Runtime Environments are limited compared to modern standards. The pure Java version does not handle formats such as MPEG-2, MPEG-4, Windows Media, RealMedia, most QuickTime files, or Flash content beyond version 2 without additional plugins; MP3 support requires separate plugins as well. While performance packs provide access to native media libraries on Linux, Solaris, and Windows platforms, cross-platform consistency in format support remains lacking—especially from the perspective of Windows developers expecting broader compatibility.
Despite its utility, Oracle’s freely available JMF implementation has seen minimal updates or maintenance since 1999. API improvements have been scarce, third-party extensions remain limited, and content editing capabilities are basic—primarily confined to fundamental audio/video recording and playback functions.
Platforms outside Oracle’s official support rely on their respective Java vendors for maintenance. Although Sun once hosted discussion forums for community engagement, several open-source alternatives have since emerged to overcome codec limitations. Projects such as Jffmpeg, Fobs4JMF, FMJ, and Xuggler offer enhanced codec compatibility with ongoing development efforts aligned with FFMPEG.
Alternative Solutions
Developers looking for multimedia libraries other than JMF have a variety of options that may better suit their needs:
- Freedom for Media in Java (FMJ) – an open-source library compatible with JMF’s API
- QuickTime for Java
- IBM's MPEG-4 Toolkit
- Jffmpeg
- vlcj
- gstreamer-java
- Cortado – a Java applet designed to play Ogg Vorbis and Theora formats
- DirectShow <> Java Wrapper
- JLayer MP3 decoding library
- Video4Linux4Java
- Java MP4 Parser Java MP4 Parser
Sample Code
The following example illustrates how to use an AWT file chooser dialog to select and play a media file through JMF.
<syntaxhighlight lang="java"> import javax.media.*; import java.io.File; import java.awt.*;
public class TrivialJMFPlayer extends Frame {
public static void main(String[] args) {
try {
Frame frame = new TrivialJMFPlayer();
frame.pack();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
public TrivialJMFPlayer()
throws java.io.IOException,
java.net.MalformedURLException,
javax.media.MediaException {
FileDialog fileDialog = new FileDialog(this, "TrivialJMFPlayer", FileDialog.LOAD);
fileDialog.setVisible(true);
File selectedFile = new File(fileDialog.getDirectory(), fileDialog.getFile());
Player player = Manager.createRealizedPlayer(selectedFile.toURI().toURL());
Component visualComponent = player.getVisualComponent();
add(visualComponent);
player.start();
}
} </syntaxhighlight>
The essential JMF functions here include Manager.createRealizedPlayer(), which generates and prepares a Player instance from the media URL, and getVisualComponent(), which obtains the AWT component responsible for rendering playback. Additional user interface controls can be incorporated using getControlPanelComponent(). This method abstracts away specific media format handling, allowing playback of any format supported by JMF.