<< Previous | Home

Running 32-bit JavaFX 2.1 Beta SDK On 64-bit Ubuntu 11.10

[Update Fri Feb 3 21:59:05 CST 2012] I started this blog a few days ago with the goal of playing JavaFX videos on 64-bit Ubuntu Linux. It turned out to be a longish post. So I'll just put the result here at the top, showing one of the video playing JavaFX 2 program at work. (This is an example from the upcoming Apress book Pro JavaFX 2 Platform. It's written by Dean Iverson. Thanks Dean.)

Tobias left a comment on the JavaFX 2.1 SDK Developer Preview Comes To Linux post 7 days ago:

Comment from Tobias on January 26, 2012 2:59:02 AM CST #:

Hi,

I think it is really nice to have an early preview of JavaFX 2.1 on Linux. However, I am also on a 64-bit Ubuntu and I cannot find out how to add the 32-bit libraries -- as soon as I try one of the 386 or multiarch versions, synaptics wants to remove hundreds of packages that I use daily.

I am really happy with JavaFX 2, which I believe is the best way to work with Java today -- but I am very tired of having to use VirtualBox and Win7 to get it working, so any help in installing the correct libraries would be great!

Let us hope that Oracle gives JavaFX on Linux the love it needs and deserves! I think they will.

According to the release notes, JavaFX 2.1 Developer Preview for Linux requires

  • Ubuntu Linux 10.04 or higher (32 or 64 bit)
  • JDK 6 update 26 or higher
  • GTK+ 2 2.18 or higher
  • libavcodec (for media)

Since the JavaFX 2.1 Beta SDK is 32-bit, I need 32-bit versions of the dependencies. On my 64-bit Ubuntu 11.10, I have already installed the 32-bit Sun JRE using Synaptic by installing the ia32-sun-java6-bin package. This package has a dependency ia32-lib which contains the 32-bit GTK+. There is no 32-bit Oracle JDK in the 64-bit Ubuntu's repositories, but it can be easily downloaded from Oracle's JDK download page. I downloaded the 32-bit JDK 7 update 2. With these software installed, I can start the sample programs such as the Ensamble.jar.

JavaFX Ensamble running in Linux

The dependency libavcodec turns out to be more problematic. Synaptic does show a libavcodec53:i386 package. But it is marked to be in conflict with the 64-bit version of libavcodec53. And if I choose to install it, 12 64-bit packages will be removed, including libavcodec53 and its dependencies, among them gnome. Apparently that is not desirable. Plus, the JavaFX 2.1 shared object that has a dependency on libavcodec is fxavcodecplugin.so. It is linked against libavcodec.so.52:

weiqi@gao:/opt/javafx-sdk2.1.0-beta/rt/bin$ LD_LIBRARY_PATH=. ldd  fxavcodecplugin.so 
	linux-gate.so.1 =>  (0xf76e1000)
	libgstreamer-lite.so => ./libgstreamer-lite.so (0xf75ec000)
	libgobject-2.0.so.0 => /usr/lib32/libgobject-2.0.so.0 (0xf7575000)
	libgthread-2.0.so.0 => /usr/lib32/libgthread-2.0.so.0 (0xf756e000)
	librt.so.1 => /lib32/librt.so.1 (0xf7565000)
	libglib-2.0.so.0 => /lib32/libglib-2.0.so.0 (0xf746c000)
	libavcodec.so.52 => not found
	libpthread.so.0 => /lib32/libpthread.so.0 (0xf7451000)
	libc.so.6 => /lib32/libc.so.6 (0xf72d6000)
	libm.so.6 => /lib32/libm.so.6 (0xf72ac000)
	libgmodule-2.0.so.0 => /usr/lib32/libgmodule-2.0.so.0 (0xf72a7000)
	libffi.so.6 => /usr/lib32/libffi.so.6 (0xf72a0000)
	libpcre.so.3 => /lib32/libpcre.so.3 (0xf7261000)
	/lib/ld-linux.so.2 (0xf76e2000)
	libdl.so.2 => /lib32/libdl.so.2 (0xf725b000)

So I have to somehow get the content of the package of the 32-bit libavcodec52, probably from an earlier Ubuntu release, without going through Synaptic, The easiest way to do this is through the Ubuntu Packages website. A few minutes of poking around reveals that libavcodec52 is available from Lucid Lynx (10.04), Maverick Meerkat (10.10), and Natty Narwhal (11.04). I choose to download it from http://packages.ubuntu.com/lucid/libavcodec52. I also downloaded all its dependencies (except libc6 and zlib1g, which I'm pretty sure is already part of ia32-lib. Here's the list of *.deb files I downloaded:

weiqi@gao$ ls -l *deb
-rw-rw-r-- 1 weiqi weiqi 4470450 2012-02-03 20:42 libavcodec52_0.6.4-0ubuntu0.11.04.1_i386.deb
-rw-rw-r-- 1 weiqi weiqi   78724 2012-02-03 20:41 libavutil50_0.6.4-0ubuntu0.11.04.1_i386.deb
-rw-rw-r-- 1 weiqi weiqi   27556 2012-02-03 20:42 libgsm1_1.0.13-3_i386.deb
-rw-rw-r-- 1 weiqi weiqi   16594 2012-02-03 20:43 libogg0_1.2.0~dfsg-1_i386.deb
-rw-rw-r-- 1 weiqi weiqi  158080 2012-02-03 20:42 liborc-0.4-0_0.4.11-2_i386.deb
-rw-rw-r-- 1 weiqi weiqi  255362 2012-02-03 20:42 libschroedinger-1.0-0_1.0.10-2_i386.deb
-rw-rw-r-- 1 weiqi weiqi  112208 2012-02-03 20:43 libspeex1_1.2~rc1-1ubuntu1_i386.deb
-rw-rw-r-- 1 weiqi weiqi  357600 2012-02-03 20:43 libtheora0_1.1.1+dfsg.1-3_i386.deb
-rw-rw-r-- 1 weiqi weiqi   33602 2012-02-03 20:44 libva1_1.0.8-3_i386.deb
-rw-rw-r-- 1 weiqi weiqi   93674 2012-02-03 20:44 libvorbis0a_1.3.2-1ubuntu1_i386.deb
-rw-rw-r-- 1 weiqi weiqi  116528 2012-02-03 20:45 libvorbisenc2_1.3.2-1ubuntu1_i386.deb
-rw-rw-r-- 1 weiqi weiqi  236094 2012-02-03 20:45 libvpx0_0.9.6-1_i386.deb

Now I can extract the content of these *.deb files with the following command:

weiqi@gao$ for x in *.deb; do dpkg -x $x /opt/libavcodec52-i386; done

This will populate the /opt/libavcodec52-i386/usr/lib directory with the shared objects needed by the JavaFX 2.1 Beta SDK:

weiqi@gao:/opt/libavcodec52-i386/usr/lib$ ls
dri                    liborc-test-0.4.so.0           libva.so.1
i686                   liborc-test-0.4.so.0.11.0      libva.so.1.0.8
libavcodec.so.52       libschroedinger-1.0.so.0       libvorbisenc.so.2
libavcodec.so.52.72.2  libschroedinger-1.0.so.0.10.0  libvorbisenc.so.2.0.8
libavutil.so.50        libspeex.so.1                  libvorbis.so.0
libavutil.so.50.15.1   libspeex.so.1.5.0              libvorbis.so.0.4.5
libgsm.so.1            libtheoradec.so.1              libvpx.so.0
libgsm.so.1.0.12       libtheoradec.so.1.1.4          libvpx.so.0.9
libogg.so.0            libtheoraenc.so.1              libvpx.so.0.9.6
libogg.so.0.7.0        libtheoraenc.so.1.1.2          sse2
liborc-0.4.so.0        libtheora.so.0
liborc-0.4.so.0.11.0   libtheora.so.0.3.10

Finally, I need to tell the 32-bit Java process where to find these shared objects. I accomplish this with setting the LD_LIBRARY_PATH environment variable:

weiqi@gao$ export LD_LIBRARY_PATH=/opt/libavcodec52-i386/usr/lib

Now, I can run JavaFX media programs on my 64-bit Ubuntu 11.10 box. One of the results is shown at the beginning of the post.

For those who trust this website, (which you in general shouldn't, unless you know me personally or pseudo-personally) here's a file that you may be interested in getting. :)

Tags :

JavaFX 2.1 SDK Developer Preview Comes To Linux

Looking back at my series of blogs on the topic of JavaFX and Linux:

makes me feel it is natural for me to blog about another significant development between JavaFX and Linux, namely, the availability of JavaFX 2.1 SDK Developer Preview on the Linux platform.

I don't know about you, but I learned of the news on Twitter:

@AdamBien: JavaFX 2.0 Is Available On ...Linux: JavaFX 2.0 SDK is available for Linux as Developer Preview Download. Enjoy ... bit.ly/zCBCgp

The official announcement (3 days ago) is here.

The beta is a 32-bit release, and requires Ubuntu 10.04 or later or equivalent, and requires JDK 7 Update 2. To give it a spin, I downloaded the JavaFX 2.1 SDK Developer Preview for Linux, the *.tar.gz version of 32-bit JDK 7. Untarred them into the /opt directory, resulting in

  • /opt/javafx-sdk2.1.0-beta
  • /opt/jdk1.7.0_02

I use JetBrain's IntelliJ IDEA for my day to day Java development. And it is really easy to work with JavaFX 2.0 in IDEA. First I add the 32-bit JDK 7 Update 2 as a JSDK to IDEA. Then I create a Java project, change it's JDK to the 32-bit JDK (for me the default is JDK 6 Update 26 that comes with Ubuntu). Finally I add /opt/javafx-sdk2.1.0-beta/rt/lib/jfxrt.jar as a dependency to the main module of the newly created project.

That's exactly the same way I setup JavaFX projects on Windows and Mac OS X. Moreover, the code I write is also exactly the same as on Windows or Mac OS X. The following is a short screen capture video (in the open source Ogg Theora format that works on some browsers on some operating systems but not others (HTML 5 is great!)) showing how the Lissajous curve (Wikipedia page) example that I posted 15 days ago is working on my Ubuntu 11.10 box.

I just want to make one point about 32-bit vs. 64-bit software on 64-bit operating systems. (If you are on a 32-bit operating system, you cannot use anything 64-bit period.) Since JavaFX 2.1 contains native libraries, the size of the JDK must match the size of the JavaFX. Since the native portion of the JavaFX 2.1 SDk has dependencies beyond the JDK, all of those dependencies must be present in a size that matches the SDK.

Since I'm on 64-bit Ubuntu, most of the shared libraries are available as 64-bit. And not all of them are available as 32-bit shared libraries. That is the case for libavcodec.so.52, which is needed by JavaFX SDK's fxavcodecplugin.so for playing MP3 audio.

And another thing worth worrying is the video hardware. My PC is three years old and contains an Intel GMA 3100 video card. When I ran the program, Prism falls back to the Java2D pipeline.

I hope Oracle is also working on a 64-bit version of JavaFX SDK for Linux.

What this earlier than expected release of a Linux version of the JavaFX 2.1.0 SDK Developer Preview shows is that the JavaFX team is committed to the cross platform vision of Java, is serious about delivering compelling technologies to make it easy and enjoyable to develop rich client Java applications, and is putting JavaFx in a position to be leveraged by thoughtful developers and companies to fuel the next round of innovations. (Like Ruby before Rails, and Objective-C before iPhone and iOS,)

Tags :

Today's St. Louis JUG Meeting Is Canceled

Just a note to let everyone know that we decided to cancel today's St. Louis JUG meeting due to inclement weather. We hope to reschedule the presentation in a future St. Louis JUG meeting.

Tags :