XUGGLER and Java 1.6 on a Mac

I am currently investigating various open source API solutions for dealing with video in real-time for water-marking, captions etc etc and I have discovered xuggler.com. At first sight it seems awesome and so I downloaded and installed the kit and started my first program only to be greeted by this error :-

[scharles]xuggler $ javac -cp /usr/local/xuggler/share/java/jars/xuggle-xuggler.jar RW1.java
RW1.java:3: cannot access com.xuggle.mediatool.IMediaReader
bad class file: /usr/local/xuggler/share/java/jars/xuggle-xuggler.jar(com/xuggle/mediatool/IMediaReader.class)
class file has wrong version 50.0, should be 49.0
Please remove or make sure it appears in the correct subdirectory of the classpath.
import com.xuggle.mediatool.IMediaReader;
                            ^
1 error
[scharles]xuggler $ 

Having used Java since it came out, I have seen this error more than once(!) and I knew what the trouble was instantly but to remedy the situation took me a little longer to figure out but in the end it is quite simple.

You What ?

The cause of the error is simple, the JAR files supplied by Xuggler are compiled with Java version 1.6 but my Mac was still using 1.5 as the default, confirmed by asking the compiler to show its mettle :-

[scharles]xuggler $ javac -version
javac 1.5.0_22

So how does one sort this out on a Mac ? Easy peasy lemon squeazy… Inside the Applications folder is the Utilities folder. Inside there is the Java Preferences folder and upon launching it, I was presented with this which showed me that although I had 1.6 installed I was still using ‘J2SE 5.0′ aka 1.5!

Java 1.5 Active

Java 1.5 Active

And the solution is….

All we need to do then is drag the ‘J2SE 5.0′ down to second position in both lists to keep things balanced and to avoid confusion about who is running what, like so.

Java 1.6 Active

Java 1.6 Active

Then issuing the version command this time shows…

[scharles]xuggler $ javac -version
javac 1.6.0_17

And lo and behold my xuggler programs start to build with no problems, so there you go, a simple solution to a somewhat mystifying initial error message.

Once I get my head around using xuggler and have to things that I want to have a pop at, firstly I want to use Clojure as the application language as I love LISP anyway and Clojure is perfect on the JVM, (IMHO!) and secondly I want to see if I can use the real-time aspects of xuggler without red5 being required on the scene. I have used and played with red5 before and to be honest I just didn’t get along with it!! Maybe it has improved in the last eighteen months.

I also want to maybe modify the source code to the awesome flvstreamer application and adding some options to it if I need to although off the top of my head I think it can actually forward data. Whatever. We’ll see…

Enjoy. :)

Published: January 6th, 2010 at 13:26
Categories: Java, video, xuggler
Tags: , ,