Weblogic MBean Example (ExecuteQueueRuntime)

September 9, 2009 · 1 Comment
Filed under: Featured, Weblogic 

The aim of this tutorial is to connect to a Weblogic MBean from a remote client and extract some Information We will be connecting to the ExecuteQueueRuntime Mbean and getting the idle thread count . Leave any questions or problems as comments and I will endeavour to answer them.

This article assumes that you have a compatible version of Weblogic installed and running and you have a compatible version of the JDK aswell.

Versions used in this example

Sofware/Component Image
Weblogic Server 8.1 N/A
JDK 1.4.2 N/A

Links to these files can be found here

In the source file you are connecting to the admin port on weblogic.

Please make sure the the java versions on your weblogic server and the java version on the client machine are the same or else you will get incompatible serialVersionUID errors like the ones below.

<9/09/2009 01:22:39 PM EST> <Error> <RJVM> <BEA-000503> <Incoming message header or abbreviation processing failed java.io.InvalidClassException: javax.management.ObjectName; local class incompatible: stream classdesc serialVersionUID = -5467795090068647408, local class serialVersionUID = 1081892073854801359


Write and Compile the Example

  1. Write the client code and save it as WeblogicMBeanExample.java in your working directory. Make sure you edit the url, username and password to match your system. The url is basically your weblogic admin url.
     1. import java.util.*;
     2. import java.rmi.RemoteException;
     3. import javax.naming.*;
     4. import java.io.*;
     6. import weblogic.jndi.Environment;
     7. import weblogic.management.MBeanHome;
     8. import javax.management.ObjectName;
     9. import weblogic.management.runtime.ExecuteQueueRuntimeMBean;
    11. public class WeblogicMBeanExample{
    13.     public static void main(String[] args){
    14.         new WeblogicMBeanExample().GoBeans();
    15.     }
    17.     public void GoBeans(){
    18.         MBeanHome home;
    19.         String url = "t3://myhost:7001";
    20.         String username = "weblogic";
    21.         String password = "password123";
    23.         ExecuteQueueRuntimeMBean mbeanExecuteQueueRuntime;
    24.         Set mbeanSet;
    25.         Iterator mbeanIterator;
    27.         try{
    28.             Properties prop = new Properties();
    29.             prop.put(Context.INITIAL_CONTEXT_FACTORY, 
    30.                 "weblogic.jndi.WLInitialContextFactory");
    31.             prop.put(Context.PROVIDER_URL, url);
    32.             prop.put(Context.SECURITY_PRINCIPAL, username);
    33.             prop.put(Context.SECURITY_CREDENTIALS, password);
    35.             Context ctx = new InitialContext(prop);
    36.             home = (MBeanHome) ctx.lookup(MBeanHome.ADMIN_JNDI_NAME);
    37.             mbeanSet = home.getMBeansByType("ExecuteQueueRuntime");
    38.             mbeanIterator = mbeanSet.iterator();
    40.             while(mbeanIterator.hasNext()){
    41.                 mbeanExecuteQueueRuntime = 
    42.                                 (ExecuteQueueRuntimeMBean)mbeanIterator.next();
    43.                 ShowInfo(mbeanExecuteQueueRuntime);
    44.             }
    45.         }catch (Exception e){
    46.             e.printStackTrace();
    47.         }
    49.     }
    51.     static void ShowInfo(ExecuteQueueRuntimeMBean meqr){
    52.         try{
    53.             System.out.print(meqr.getName());
    54.             System.out.print("\t\t"+meqr.getExecuteThreadCurrentIdleCount());
    55.             System.out.print("\t\t"+meqr.getParent().getName());
    56.         }catch(Exception e){
    57.             System.out.print("\t\tError");
    58.             e.printStackTrace();
    59.         }
    60.         finally{
    61.             System.out.println("\n");
    62.         }
    63.     }
    64. }

    Hide line numbers

  2. You need the weblogic.jar to compile this. I strongly suggest you take a copy of the weblogic.jar file from the weblogic server you are trying to connect to. This will limit any incompatibility issues. Copy the weblogic.jar file to your working directory. It should be with your source file.
  3. Now open a promt to where you saved the file and compile it.
    javac -classpath .;weblogic.jar WeblogicMBeanExample.java
  4. Now run it.
    java -cp .;weblogic.jar WeblogicMBeanExample

Uploading Files with a Multipart POST

August 13, 2009 · Leave a Comment
Filed under: JAVA 

Uploading Files with a Multipart POST

11.9.1. Problem

You need to upload a file or a set of files with an HTTP multipart POST.

11.9.2. Solution

Create a MultipartPostMethod and add File objects as parameters using addParameter( ) and addPart( ). The MultipartPostMethod creates a request with a Content-Type header of multipart/form-data, and each part is separated by a boundary. The following example sends two files in an HTTP multipart POST:

import org.apache.commons.httpclient.HttpClient;

import org.apache.commons.httpclient.HttpException;

import org.apache.commons.httpclient.methods.MultipartPostMethod;

import org.apache.commons.httpclient.methods.multipart.FilePart;

HttpClient client = new HttpClient( );

// Create POST method

String weblintURL = “http://ats.nist.gov/cgi-bin/cgi.tcl/echo.cgi“;

MultipartPostMethod method =

new MultipartPostMethod( weblintURL );

File file = new File( “data”, “test.txt” );

File file2 = new File( “data”, “sample.txt” );

method.addParameter(“test.txt”, file );

method.addPart( new FilePart( “sample.txt”, file2, “text/plain”,

“ISO-8859-1″ ) );

// Execute and print response

client.executeMethod( method );

String response = method.getResponseBodyAsString( );

System.out.println( response );

method.releaseConnection( );

Two File objects are added to the MultipartPostMethod using two different methods. The first method, addParameter( ), adds a File object and sets the file name to test.txt. The second method, addPart(), adds a FilePart object to the MultipartPostMethod. Both files are sent in the request separated by a part boundary, and the script echoes the location and type of both files on the server:

<h3>Form input</h3>


sample.txt = /tmp/CGI14480.4 sample.txt {text/plain; charset=ISO-8859-1}

test.txt = /tmp/CGI14480.2 test.txt {application/octet-stream;



11.9.3. Discussion

Adding a part as a FilePart object allows you to specify the Multipurpose Internet Main Extensions (MIME) type and the character set of the part. In this example, the sample.txt file is added with a text/plain MIME type and an ISO-8859-1 character set. If a File is added to the method using addParameter( ) or setParameter( ), it is sent with the default application/octet-stream type and the default ISO-8859-1 character set.

When HttpClient executes the MultipartPostMethod created in the previous example, the following request is sent to the server. The Content-Type header is multipart/form-data, and an arbitrary boundary is created to delineate multiple parts being sent in the request:

POST /cgi-bin/cgi.tcl/echo.cgi HTTP/1.1

User-Agent: Jakarta Commons-HttpClient/3.0final

Host: ats.nist.gov

Content-Length: 498

Content-Type: multipart/form-data; boundary=—————-31415926535



Content-Disposition: form-data;.txt; filename=test.txt

Content-Type: application/octet-stream; charset=ISO-8859-1

Content-Transfer-Encoding: binary

This is a test.


Content-Disposition: form-data;.txt; filename=sample.txt

Content-Type: text/plain; charset=ISO-8859-1

Content-Transfer-Encoding: binary

This is a sample


Each part contains a Content-Disposition header to name the part and a Content-Type header to classify the part with a MIME type and character set.

Platform as a Service — Project Caroline (Sun Microsystems)

March 28, 2009 · 2 Comments
Filed under: Featured, General, JAVA 

Project Caroline Overview

Project Caroline is developing a horizontally scalable platform for the development and deployment of Internet services. The initial design center is to make the platform available as a utility, where a pool of virtualized resources is shared between many customers each with one or more services. Through the utility model services can dynamically flex their usage of the platform’s distributed resources up and down, matching usage to observed load. The horizontal scalability of the platform allows for the efficient delivery of resources and supports a pay-for-use (verses pay-for-capacity) billing model. Customers of the utility are isolated from each other and mechanisms are provided for the isolation of services.

The primary resource provided by Project Caroline is a set of horizontally scaled machines for running customer processes. Customers specify for each process the program to run, what networked file systems it should have access to, and IP addresses it should be reachable at. The platform takes care of the details of finding a machine for the process to run on, configuring the machine, network, and Internet connectivity. Operating system-level virtualization is used to isolate processes sharing the same physical machine while keeping per-process overhead low. Customer programs are expressed in languages like Java byte code, perl, and python that provide OS and instruction set independence. Other resources include IP sub-nets, network file systems, databases, external IP addresses, L4 and L7 load balancers, and DNS bindings. Applications can allocate, configure, and release these resources using the platform API. Through the platform API, applications can acquire and release resources in seconds.

In addition to the platform API, various tools and components have been layered on top of the platform API, including: cash, a Ruby-derived interactive shell; a standalone GUI and a NetBeans plug-in for direct manipulation of Project Caroline resources; a set of (J)Ruby centric tools for using Project Caroline; Apache Ant tasks for easily automating the creation and management of Project Caroline resources; and macro-components such as the Project Caroline Web Server (based on Project GlassFish v3) which automates setup and management of a horizontally-scaled web tier.


Hibernate LazyInitializer error in tomcat

March 24, 2009 · Leave a Comment
Filed under: Featured, Hibernate, JAVA 



caused by:
org.apache.jasper.JasperException: java.lang.Object.getHibernateLazyInitializer()Lorg/hibernate/proxy/LazyInitializer;
caused by:
javax.servlet.ServletException: java.lang.Object.getHibernateLazyInitializer()Lorg/hibernate/proxy/LazyInitializer;
caused by:
java.lang.NoSuchMethodError: java.lang.Object.getHibernateLazyInitializer()Lorg/hibernate/proxy/LazyInitializer;

After using the web client for a few minutes.


   I keep getting this error: javax.faces.FacesException: java.lang.Object.getHibernateLazyInitializer()Lorg/hibernate/proxy/LazyInitializer; caused by: org.apache.jasper.JasperException: java.lang.Object.getHibernateLazyInitializer()Lorg/hibernate/proxy/LazyInitializer; caused by: javax.servlet.ServletException: java.lang.Object.getHibernateLazyInitializer()Lorg/hibernate/proxy/LazyInitializer; caused by: java.lang.NoSuchMethodError: java.lang.Object.getHibernateLazyInitializer()Lorg/hibernate/proxy/LazyInitializer; After using the web client for a few minutes.

This exception is usually due to the JVM not being run with the -server option. The startup.bat/sh scripts set up the appropriate JAVA_OPTS.


FMJ Project

February 9, 2009 · 2 Comments
Filed under: Featured, FMJ, FMJ Project, JAVA 


FMJ Project

FMJ is an open-source project with the goal of providing an alternative to Java Media Framework (JMF), while remaining API-compatible with JMF. It aims to produce a single API/Framework which can be used to capture, playback, process, and stream media across multiple platforms.

Since FMJ is API-compatible with latest JMF, you may use existing JMF codes and run them. However, several areas of the project are under development, and sometimes you may have to find workarounds, if your existing JMF codes do not work. At any time feel free to ask us questions on our help forum. You can also browse through our getting started, troubleshooting and javadoc pages. This documentation will help you undestand the difference and similarities between JMF and FMJ.

FMJ also has two sub-projects and one sister project. The sub-projects, FFMPEG-Java and Theora-Java, are Java wrappers for FFMPEG and Vorbis respectively. Our sister project is LTI-CIVIL and it is used as the primary video capture device library.

FMJ can be downloaded here in ZIP or TAR bundles, or you can directly pull the latest source from CVS.

You are always welcome to join the team, because this is a big project with lots to do!

By the way, do not forget to check out screenshots and live demo sections!



Default JRE

Java Runtime Environment 5.0

Supported Formats

Visit our supported media formats page.

Supported Platforms

GNU/Linux 32/64-bit
Kernel 2.4+

Windows 2000/XP/Vista

Mac OS X


JMF wrapper for ffmpeg

February 9, 2009 · Leave a Comment
Filed under: Featured, JAVA, JMF 



Try FOBS, the C++ & JMF wrapper for ffmpeg.

Omnividea Multimedia and the computer vision group at UPM-DISAM present FOBS: Ffmpeg OBjectS. FOBS is a set of object oriented APIs to deal with media. It relies in the ffmpeg library, but provides developers with a much simpler programming interface.

FOBS is currently available in C++. The Java side (Fobs4JMF) has been implemented as a JMF plugin that allows to use JMStudio as a Java Media Jukebox to play the most common formats and codecs (ogg, mp3, m4a, divx, xvid, h264, mov, avi, etc). Binaries for this enhanced version of JMStudio are available at the downloads section for Windows, Linux and Mac OSX. Developers can use the same binaries to include support for many more formats & codecs into their own JMF applications without changing a line of code!


Lame Installation

February 8, 2009 · Leave a Comment
Filed under: Featured, JAVA, Lame 

While the LAME source code is free, the encoding technology that ready-compiled LAME binaries use is patented. The patents are held by Fraunhofer and administered by Thomson. Patenting raises a theoretical possibility that in some countries a user might need to pay a licence fee to legally encode MP3s. This might vary according to the purpose of the encoding and whether the software being used is licensed.

There is no definitive list of countries where the patents unambiguously hold sway. However they are generally assumed to be enforceable in USA, Canada, the EEC and Japan. This means that in these countries (in theory), software that encodes MP3s must be licensed by the patent holders, and that anyone encoding MP3s with unlicensed encoders may also be infringing patents.

The best advice that can be given is that the user makes their own decision, based on their conscience, the country they are in, and taking into account the following:

·       The patent holders have tended to enforce license fees against commercial rather than free MP3 encoders

·       Thomson themselves have said that no license is needed by individuals creating music libraries of MP3 files for personal use (interpretations vary whether that sanctions using unlicensed encoders, free or otherwise)

·       MP3 patents will expire worldwide between 2010 and 2012

Windows Instructions

New or inexperienced users are recommended to follow the easy steps in the Simple Installation section and skip the "Advanced options for MP3 encoding" section that follows "Simple Installation".    

Simple Installation

 All users

1.      Download an unzipped copy of the required lame_enc.dll

2.      Do not open this file, but save it to your computer. As you will be using this .dll file directly for encoding it is recommended to save it into your installation folder.

A higher bit rate gives you higher quality at the expense of a larger filesize, and vice-versa. A 128 kbps bit rate takes up about 1 MB of space per minute. The "Options" button also gives access to more advanced MP3 encoding options as follows:

1.      Bit Rate Mode (Variable, Average, Constant or use a Preset)

2.      Encoding Speed (with other than constant bit rate encoding)

3.      Channel mode (currently Stereo or Joint Stereo).

Mac Instructions

Downloading and installing

OS 9
Download: LameLib-Carbon-3.91.sit

Download: Lame Library v3.98.2

Note: this requires OS X 10.4 or later. For OS X 10.2 or 10.3, download libmp3lame-osx-universal-3.97.zip

Universal Binary for Intel Macs and Power PCs
Download: Lame Library v3.98.2

Note: this requires OS X 10.4 or later. For OS X 10.3, download libmp3lame-osx-universal-3.97.zip

Next, go to the instructions for LameLib-Carbon-3.91.sit, Lame Library v3.98.2 for Audacity.dmg or libmp3lame-osx-universal-3.97.zip.


1.      When you have finished downloading, extract the files with Stuffit or similar (this may happen automatically)

2.      Save the file called "LameLib" anywhere on your computer

Extra help with expanding .sit files:

Try Stuffit. It has several ways to expand a compressed file:

·       Double-click the icon of the file. On many systems, StuffIt will launch and expand the file.

·       Using your mouse, click and hold the icon of the file, then drag it over the icon of StuffIt. When StuffIt’s icon darkens, release the mouse button. StuffIt will open and expand the file, and then quit.

·       Double-click StuffIt’s icon, and wait for it to open. From the File menu, select Expand, and in the window that appears, find the file want to expand. StuffIt will then expand the file.

·       With StuffIt open, from the Window menu, select Drag Window. To expand your file, drag it into the Expander window that opens.

Alternative expanders for sit:

·       Springy        

Lame Library v3.98.2

1.      When you have finished downloading, double-click the .dmg to mount it, then go to the Finder (in Safari, "Lame Library v3.98.2 " will be extracted automatically after downloading).

2.      Double-click "Lame Library v3.98.2". This will install the LAME binary "libmp3lame.dylib"


1.      When you have finished downloading, use an expander such as Stuffit or Springy to extract the files

2.      Save the file "libmp3lame.dylib" anywhere on your computer – it’s located at the bottom of the "package" folder at libmp3lame-osx-universal-3.97/package/usr/local/lib

Setting bit rate and other options

A higher bit rate gives you higher quality at the expense of a larger filesize, and vice-versa. A 128 kbps bit rate takes up about 1 MB of space per minute. The "Options" button also gives access to more advanced MP3 encoding options as follows:

1.      Bit Rate Mode (Variable, Average, Constant or use a Preset)

2.      Encoding Speed (with other than constant bit rate encoding)

3.      Channel mode (currently Stereo or Joint Stereo

Previous Intel Mac naming issue with Universal Binary

An early version of http://spaghetticode.org/lame/libmp3lame-osx-universal-3.97.zip mistakenly named the included MP3 encoding binary as libmp3lame.so instead of the libmp3lame.  If you have this problem, please download the latest version.

Assertion error with LAME on Power PCs

Users on Power PCs may see an "assertion error" when exporting MP3s. This is due to a bug in the LameLib binary. This binary is v3.91 and outdated, but unfortunately is the only carbonised version that is currently available.

GNU/Linux/Unix instructions

Obtaining LAME

Most Linux distributions have some sort of package manager that fetches software packages from the Internet in .deb or .rpm format, and installs them for you. Open that package manager, search for LAME, and install it if it is not already installed. There are detailed instructions below for installing LAME by using the Synaptic package manager on Ubuntu or Debian systems.

Obtaining LAME using Synaptic

These are detailed steps for Ubuntu 8.04 Hardy Heron, but should be the same for all other Debian-based distributions of Linux.

1.      Open the “Synaptic” software-package manager.

o       In GNOME (the default desktop environment for Ubuntu and many other systems), you can find it by clicking on the “System” menu at the top of the screen, and then choosing “Administration”.

o       In KDE (the desktop environment for Kubuntu and many other systems), there will be a similar menu accessible from the bottom-left of the screen.

o       In all desktop environments, you can open up a command-line terminal and type “gksu synaptic” or “sudo synaptic”.

2.      Enter your Ubuntu user password when asked for it.

3.      In the Synaptic window, choose “Settings”, then “Repositories”.

4.      In the Ubuntu Software tab check the box for Software restricted by legal or copyright issues (“multiverse”), and then the Close button

5.      Back in the main Synaptic Window click the search button, choose to search by name only, then type “lame” and click “Search”.

6.      In the search results list, you will see the packages “lame” and “liblame0”. Mark both for installation (by double-clicking).

7.      Click the "Apply" button, and on “OK” to any warnings that come up.

8.      The LAME software will automatically download and install. Close the Synaptic window when it has finished.

Obtaining LAME using APT on the command line

Behind the scenes, Synaptic uses a program called APT. You can directly use APT to install LAME. First, open up a program such as xterm, GNOME-Terminal or Konsole, that gives you access to the command line.

Assuming that LAME is available in one of the repositories listed in /etc/apt/sources.list, you can install LAME with the following command:

sudo apt-get install lame liblame0

You will be asked for your user password. LAME will then download and install.

Some Linux systems do not use sudo. In that case, ente

r these three commands:


apt-get install lame liblame0



yum  install lame



You will be asked for your root password.

LAME from source

If there isn’t a LAME package for your distribution, go to the LAME Project home page and download the latest source code. Compile it as a shared object, it will be at /usr/local/lib/libmp3lame.so.

This is for advanced users. Newer users are advised to look for a LAME package for their distribution.

 * in older versions , there had to be no “.0” on the end, and users actually had to rename the file to make it conform to this expectation.

HINT: If you want to choose specific sample rate/bit rate combinations, the following shows those permitted in the MP3 specification, (with or without resampling):

MPEG-1 layer III sample frequencies (kHz): 32 48 44.1:
bit rates (kbps): 32 40 48 56 64 80 96 112 128 160 192 224 256 320

MPEG-2 layer III sample frequencies (kHz): 16 24 22.05:
bit rates (kbps): 8 16 24 32 40 48 56 64 80 96 112 128 144 160

MPEG-2.5 layer III sample frequencies (kHz): 8 12 11.025:
bit rates (kbps): 8 16 24 32 40 48 56 64 80 96 112 128 144 160

Exported MP3 plays too fast

If the MP3 plays at the wrong speed (usually too fast), then the sample rate you exported it at is unsuitable for your player application. Once again, the safe solution is to always set your Project Rate to 44100 Hz. This was a known problem with Adobe Flash Player until some way into version 9: for the file to play properly, the sample rate had to be 11025 Hz or a multiple thereof, such as 22050 Hz or 44100 Hz. This is fixed in the current Adobe Flash Player.

Exported MP3 has low volume or no sound

If you can see your exported MP3 is playing because the timer on the media player is moving, but it has no sound, make sure the sound device is not muted (in the player or in the system control panel), and make sure the correct playback device is being used (in the player preferences or in the system control panel

Note that reducing the export bit rate will reduce the quality of the exported file below that of the file you exported at a higher bit rate. In fact, whatever bit rate you export at, importing an MP3 file and re-exporting it as an MP3 will always lead to a further loss of quality compared to the imported MP3. Re-encoding the file as an MP3 when you export it cannot be avoided , because it always decompresses the MP3 upon import. This is essential to maintain the quality of the file when applying complex edits such as equalisation.

But if you only want to do simple cut, copy, paste, fade and volume edits to your MP3s, you can do so without audio losses in other tools that can edit the MP3s directly without decompressing and re-encoding them. Two examples are MP3DirectCut  for Windows and Linux (under Wine) and Audion  for OS X.

MP3s of the same bit rate, sample rate and channel mode can also be joined non-destructively with these tools without the need for lossy re-encoding.

A Mistake Asking to Be Re-Made

February 6, 2009 · Leave a Comment
Filed under: Featured, JAVA, JMF 

JMF: A Mistake Asking to Be Re-Made

Tuesday December 13, 2005 6:02PM
by Chris Adamson

AddThis Social Bookmark Button

Related link: http://archives.java.sun.com/cgi-bin/wa?A2=ind0511&L=jmf-interest&F=&S=&P=2852

Oh no, not again.

JMF, the Java Media Framework, has had a history that can honestly be described as alternating periods of ineptitude and neglect. The fact that the JMF home page has only seen three updates in the last two years, and none in the last twelve months, indicates that JMF is in the latter state.

And now this post to the JMF-INTEREST list:

I’m T— W—- and have recently taken responsibility for JMF at Sun
We are in the process of planning what to do with JMF and would like
hear from you
regarding how you are using JMF and what your needs are. Please feel
free to contact
me directly as some of the other feedback channels are currently not
working properly.

Oh, where to begin?

OK, before I offer any more criticism, I need to acknowledge that I’m the author of a book on QuickTime for Java, a rival Java media framework. Some may think I’m trying to goose my own book sales. Think that if you like, but the book’s been out for a year and has probably sold most of the copies that it’s ever going to.

And let me add this: I started with JMF. If it were good, I might never have moved on to QTJ. After all, QTJ is limited by the fact that it only works on platforms with native implementations of QuickTime — meaning only Mac and Windows. An all-Java media framework would be tremendously valuable to the Java platform.

But I am absolutely convinced that Sun is in no way capable of creating such a thing.

The proof of this is in the results: since its release in 1998, JMF has gained practically no traction, and has been largely ignored since the release of JMF 2.0 in late 1999. We’ve gone six years with virtually no substantive work on the framework.

A little history as to how we got here… With no experience, credibility, or patents in the media field, one might have expected Sun to take on a partner in developing JMF, someone like Macromedia (Flash), Apple (QuickTime), or Real. Instead, they developed JMF 1.0 with Intel, and 2.0 with IBM.

JMF 1.0 was quickly pulled together to enable playback of dynamic media — audio and video — in Java desktop applications. JMF 2.0 added capture, streaming, and pluggability. But because of the high demands of media and the modest performance of late 90’s VM’s (and the capabilities of the hardware they ran on), all-Java media handling realistically needed to be bolstered by native “performance packs”, which improved JMF on supported platforms by using high-performance native code, and access to the platfrorm’s native media frameworks.

So… what’s the problem? Here are a few:

  • JMF has no editing API, nor any meaningful concept of media in a stopped state. That means it can’t be used for building, say, a podcast editor (can’t trim your clips), or iTunes (no metadata API for reading the track titles). Aside: what’s the point of a capture API if there’s no way to edit the captured data (apparently, the capture is only useful for streaming applications).
  • Sun made a performance pack for Solaris, that ubiquitous champion of the desktop, and not for Mac Classic or Mac OS X.
  • The included codecs supported few media types in common use at the time, and those that were used in 1999 (Cinepak) have fallen out of use.
  • The system for managing plug-ins, the “JMF Registry”, was extremely brittle.
  • The scheme for finding an appropriate plug-in used the wildly inefficient tactic of using exceptions for program flow.
  • Sun expected Macromedia to develop the Java support for the Flash format, and Macromedia lost interest, leaving JMF supporting only Flash 2.

Now it’s six years later and what’s been done? MP3 support was taken out of JMF for a few years due to licensing concerns, then put back in. Other than that, the framework has languished. Sun got interested in JMF again in July 2002, but they couldn’t actually hire anyone to work on it, and ended up not actually doing anything with it. So, developers come along, try to discover what it can do, and often wander off in disgust that it can’t work with modern formats. Some go to QTJ; many more probably call native frameworks with JNI, or just abandon Java altogether.

Now Sun wants to know what to do with it? Seriously?

Look, nobody developing a commercial application could risk Sun walking away from JMF for another six years. And given the utter lack of interest from third parties in extending this built-to-be-extended platform — it would be straightforward to bring Real to JMF via the open-source Helix platform, but nobody seems to have bothered — there’s no realistic chance of a third party coming to the rescue.

And seriously, what’s the point? Does Sun have a strategic vision for JMF? Is there some genuine value it can bring to the Java platform? Will putting dollars into new development pay off someday? Are these questions really going to be answered by casually throwing out a “Hi, what should we do with this?” to the handful of developers who are still hanging on?

For a lot of reasons, some technical, some not, JMF is a hopeless case. Unfortunately, due to the benefits of incumbency (the prominent javax.media package), it lures developers into a Venus Fly Trap of minimal functionality and unfixed bugs.

So, Sun, do you want to know what I think you should do with JMF? Deprecate it. Stop wasting our time. Tell everyone you’re done and move on to something that might work out better.

What good could come from reviving JMF?



Hear hear!
I sure hope you emailed this to that guy, as Sun seriously needs to be told off on this. Sun already screwed the pooch by letting Flash become what it is today instead of Applets; JMF either needs to go away or be made current, and I believe what you said in doubting Sun cares enough to do it.

hexghost | December 13, 2005 06:43 PM

You missed the big problem completely
It was an interesting post Chris and while I agree with pretty much everything you said I think you missed the biggest problem that JMF and any “media” product faces: Copyright, trademarks and patents.
Its a mess out there, we recently did a project that required AMR support. Our team spent months with the patent holders for some key properties trying to get to a redistribution deal… Its just impossible to support all of these codecs and standards in a big business which is why only the “big” companies that have strong ties to the “industry” have products in this field.

So essentially the main problem is a legal rather than a technical problem and none of us (engineers) can solve it, or can we? We solved our problem by using QT4J but this eliminated Linux/Unix as a potential platform for us…

I raised a solution for this problem in my (old) blog a year or so ago http://jroller.com/page/vprise/?anchor=jmf_is_dead_jdic_should
in essense what I say in the entry is that we should rely on the fine work done by the teams at Apple, Real, Microsoft and MPlayer (or any other Linux/Unix player) by providing a reasonable API to interface into these tools. I think JDIC is the perfect vehicle since it allows Sun to maintain its “distance” from potential lawsuits that might follow.

Anyway we both definetly agree that JMF is dead and should stay dead, I do think that Sun needs to do something in this area though. Since most of us can’t rely on QT4J if only for the reason of its limited platform support.

vprise | December 14, 2005 06:22 AM

deprecate? No!
No, don’t do it! If JMF mean a wasting of time for Sun, makes what one becomes for all standard as this: It specifies it in the JCP and open it!

Copernico | December 14, 2005 06:44 AM

We need JMF or at least something similar
Hi, I am steering member of Javapolis http://www.javapolis.com. We have started last year to publish on the web videos of the Javapolis conference and will do the same this year.
When I developped the player, I was really willing to do it as a Java applet playing and navigating into MPeg4 content.
IBM had a good player, but not free, then there was an open-source player “MediaFrame” that was not stable enough at the time.
At the end, I have selected Macromedia Flash technology to develop the player. That was the first time in 5 years I was dropping Java for a new language.
I must say that I appreciate Flash for what it can do the best. Clearly, video and animations are really easy in Flash.
I do not think Java will ever compete with Flash, it is too late to jump in this bandwagon.
But definitely, multimedia capabilities are lacking in Java. We need at least MPEG-4, MPEG-2 and MPEG-1 video and MP3, AAC audio decoding with a decent API to be able to navigate into and get meta-data from that kind content.

mulkers | December 19, 2005 02:22 AM

dont stop
I just started with JMF and I am not unhappy with it. My customers are actually really happy with it.

Deprecation would make me wanna cry. I am currently using JMF in an applet. Pictures can be taken by means of capturing a frame. Installation and detection of devices goes remarkeable smooth. Also installing a VM goes well these days, the size of the VM is not a problem (dutch bandwidth). It is actually the first time for me that an applet adds something that could otherwise not be achieved. Maybe with flash but who wants to use that? I dont!

I am cool with java but the icing on the cake would be hot swap enhancement. A discussion about this on http://forum.java.sun.com/thread.jspa?threadID=572396&tstart=0

Anybody that agrees, pleas vote for it on http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4910812

Dennisb | December 29, 2005 12:53 PM

Try FOBS in conjunction with JMF
I have to say, I struggled with QTJava for a long time, just to get a simple player inside of a more complicated, resizable and proportional layout, to work properly. The movie would always disappear, or the control bar would disappear, or the program would crash, or it would play outside of its bounds, etc. The tricky part was that I needed to load multiple movies into this layout, which is when everything usually went awry. And then don’t get me started on QT updates which break everything, constantly. And installers! I do have access to the QTJ book :-)

With JMF, it all worked the first time, without any hacks required, other than FOBS. FOBS is a JMF plugin which allows you to use FFMPEG, which supports all sorts of current formats.


JMF also seems to me to be a very elegant, event-driven framework with good documentation. It can all be plunked into a single installer. Neither can be said about QTJ.

Plus this works on Linux, as well as Mac and Win.

So don’t get me wrong – I do all my work on a Mac, but JMF was much better for the seemingly simple tasks I needed it for. I know it’s not as powerful as QTJ when it comes to editing, but all I wanted was a reliable player!

Also, what was the problem with detecting a stopped state? I had no problems with that.


DiehardMM | January 9, 2006 02:42 PM

Hello, I just wrote a speeh to sms j2me programe using j2me.mmapi onf the handset and sphinx4 ( voice recognition ) and FFMpeg for Java bindings theses all support the JMF. Had not the JMF exisited could these two applications talk together? without glass in my food? no. JMF need to support things such as media signing, so say in my case the client licenses the AMR capture codec and then the license to use the AMR deocder on my server also. Why should I pay so they can decode their own content?


Warren Crossing | February 22, 2006 07:55 PM

I just wanted to bring attention to our new effort to create an open-source implementation of JMF, (FMJ, fmj.sourceforge.net), which can hopefully address some of the problems mentioned. We are still heavy in the development stage, but are looking for help…

Ken Larson | June 2, 2006 05:44 PM

LAME mp3 java sound recorder

February 5, 2009 · Leave a Comment
Filed under: Featured, JAVA, Lame 


LAME is, probably, the best MP3 encoder ever. LAME binaries have two parts :

  1. A statically linked command line: “lame.exe” on Windows, “lame” on Unixes.
  2. A dynamic link library/shared object: lame_enc.dll on Windows, libmp3lame.so on Linux and Solaris, libmp3lame.dylib on Mac OS X.

    This library exports the standard LAME API as declared in lame.h.

    The Windows version (lame_enc.dll) exports the API too, this API is backward compatible with the old BladeEnc MP3 encoder.

LAMEOnJ is a 100% Java API wrapping the standard LAME API. Under the hood the Java methods call the exported lame_enc.dll/libmp3lame.so/libmp3lame.dylib methods and LAME structures are reflected in symmetric Java classes.

To perform this “magic” LAMEOnJ classes are enhanced with JNIEasy and use the JNIEasy runtime.

JNIEasy is free to personal non-profit use using a temporary evaluation key that can be renewed (downloaded) again with no personal data provided. A commercial license has not this limitation.

LAMEOnJ has two levels or versions:

  1. A C symmetric API: Java classes and methods mimic the LAME structures and methods. The programming style is almost the same as the C style.
  2. An Object Oriented API: Java classes and interfaces encapsulating the boring tasks related to C programming in a simpler and robust Java API, and providing quick methods for encoding WAV files or WAV/LPCM streams to MP3 and decoding MP3 to WAV/LPCM.

LAMEOnJ wraps the BladeEnc API too (C and OOP version), this API is old and only provided by the Windows version of LAME (lame_enc.dll).


At Sourceforge.

LAME binaries are not included. Recommended sites to download:

  • Windows (the Mac version does not work with Mac OS X 10.4)
  • Linux: many Linux distributions include LAME binaries (or can be optionally downloaded), for instance Ubuntu packages, liblame-dev and lame.
  • Mac OS X: compile yourself (“configure” and “make”), copy or rename libmp3lame.0.0.0.dylib as libmp3lame.dylib from libmp3lame/.libs to bin/macosx86 folder.
  • Solaris:
    – Download v3.97 source code
    – Apply this patch.
    – Add gcc to the PATH, for instance:
    export PATH
    – Compile the source code:
    ./configure; ./make
    – Copy or rename libmp3lame.so.0.0.0 as libmp3lame.so from libmp3lame/.libs to bin/solarisx86 folder.
  • More links

LAME binaries are not included inside the LAMEOnJ distribution to avoid patent problems. OSTG/VA Software, the owner of the SourceForge.org site (the hosting of this project), is an EEUU company and software patents cover MP3 algorithms included in LAME. Use LAME binaries at your own risk in your country.


Decompress the .zip file, download a new JNIEasy.lic evaluation file/key and put this file in the /bin folder. When the evaluation period ends you can download again a new license file.

Download a recent LAME binary release including dynamic libraries. Decompress, copy and put the dynamic library/shared object into the concrete LAMEOnJ folder /bin/win32x86, bin/linuxx86 or bin/macosxx86.


LAMEOnJ is a development tool. The bin/<platform>/test*.bat and test*.sh files execute Java examples encoding/decoding MP3 files/streams and WAV files/streams using the low level LAME API and LAMEOnJ OOP APIs. You can use the multiplatform Ant file too (build_LAMEOnJ.xml).

LAMEOnJ is packaged as a NetBeans project, useful for editing and compiling individual files (use build_LAMEOnJ.xml for any other task).


LAMEOnJ is open source and licensed under the terms of the business friendly Lesser GNU Public License (LGPL)



  1. lame.h file documents (briefly) the LAME API.
  2. LAMEOnJ’s JavaDoc
  3. BladeEnc interface documentation.
  4. BladeMP3EncDLL.h file declaring the BladeEnc exported methods and structures.

SCJP Useful Links

January 26, 2009 · 1 Comment
Filed under: Featured, JAVA, SCJP 

http://www.go4java.20m.com/ (Basic introduction of SCJP go trough all the site to know more)

http://www.examulator.com/phezam/login.php ( Most useful test simulator )

http://www.javabeat.net/javabeat/scjp5/mocks/index.php ( Specific questoins on 1.5 new topics)

http://www.cafe4java.com/mockexams/scjp/mock1/q1.php ( 1.5 covariant return type questions)

http://www.cafe4java.com/mockexams/scjp/mock2/q1.php (1.5 File IO questions)

http://www.danchisholm.net/july21/mybook/index.html ( topic wise questions better to practice each


http://www.geocities.com/sahirshah/applets/mocktest.html ( simulator test)

http://www.lanw.com/java/javacert/TestApplet10.htm ( 1.4 simulator test)

http://bmil.freeservers.com/tester/test.html ( simulator test)








http://www.geocities.com/SiliconValley/Orchard/9362/java/javacert/ ( few of the useful links)

http://faq.javaranch.com/view?ScjpMockTests ( few useful links)




« Previous PageNext Page »