Peter Pilgrim is professional software developer, designer and architect. Since 1998 he has worked in the financial services industry, investment banking mainly, developing IT for clients. He is a well known specialist in Java Enterprise Edition (Java EE) technology, focused on the server-side and the implementation of electronic commerce. Peter has built professional Java EE apps for top-tier investment banks such as Lloyds Banking Group, UBS, Credit Suisse, Royal Bank of Scotland and Deutsche Bank. Peter is the 91st Oracle Java Champion. Peter is a DZone MVB and is not an employee of DZone and has posted 34 posts at DZone. You can read more from them at their website. View Full User Profile

Devoxx 2008 University Monday JavaFX Launches

  • submit to reddit
Welcome to the first blog issue of the Devoxx 2008 conference, which was originally titled JavaPolis, but because of commercial trademark issues with Sun Microsystems, it had to be renamed. It is a longer story. Most gratefully, Stephan Janssen, organiser and co-founder, really does a very fine job getting this massive European Java conference trucking through every single December. He is a truly great Java Champion for his herculean efforts, which I tell you, should not be underestimated. Devoxx is sold out, it is expected that 3200 people from all over the world will be stepping through the Metropolis door.

I bumped into Aaron Houston, who related a lot of changes that are going on a Sun Microsystems. Most of this you already know. Sun announced a major redundancies and there have been business restructuring across the board. If this worries you, then please rest assured that every large company, especially the mult-national ones go through revitalisation. This is change and it is evitable.

Shout Outs!

Louis Emmett, JAVAWUG speaker and member. You finally made to Java conference. Well done that man!
Aaron Houston, Sun Technology Outreach team
Carole McDonald, Sun Technology Outreach team
Michael Huettermann, Java Champion, Cologne JUG
Dave Booth, soon to be an ex-JetBrainer
Bruce Synder, the one and only
Kirk Pepperdine, Keepin' on Tuning This.
Marco Van Beelen, JAVAWUG Belgium member!
Joshua Marinacci, JavaFX Team Member
Ilya Sergey, NetBrains software engineer

(Top and right photographs courtesy of Aaron Houston)

In the last two weeks before Devoxx I was considerably time challenged, but I did upload to Vimeo the very last Java Champions BOF from JavaOne.

JavaOne 2008 Java Champions BOF from peter_pilgrim on Vimeo.

JavaFX Media Playing Problem

Here is example code for a JavaFX 1.0 media player that does not work with NetBeans 6.5 !

// MediaPlayerTestOrig.fx
package fxexamples;


import javafx.scene.paint.Color;
import javafx.ext.swing.SwingSlider;
import javafx.scene.layout.VBox;
import javafx.scene.layout.HBox;
import javafx.ext.swing.SwingButton;
import javafx.scene.Scene;
import javafx.scene.transform.Transform;
import java.lang.System;
import javafx.stage.Stage;
import javafx.scene.text.Text;
import javafx.scene.text.Font;


var playButton: SwingButton;
var pauseButton: SwingButton;
var stopButton: SwingButton;
var timeSlider: SwingSlider;


var media = Media {
        source: "{__DIR__}videos/movie.avi"
        // source: "{__DIR__}videos/WindowsMedia.wmv"

var myCurrentTime: Duration on replace {
    //    FX.println("myCurrentTime={myCurrentTime}");
    if ( not timeSlider.enabled) {
        timeSlider.value = myCurrentTime.toMillis() as Integer;

var sliderValue: Integer on replace {
    if ( player.status == player.PAUSED ) {
        player.currentTime = sliderValue * 1ms ;

var player = MediaPlayer {
    media: media
    autoPlay: false
    currentTime: bind myCurrentTime with inverse;
var view: MediaView;

var stage:Stage = Stage {
    title: "Peter Pilgrim's JavaFX Example Video Player";
    visible: true;    
    width: DEFAULT_FRAME_WIDTH as Integer;
    height: DEFAULT_FRAME_HEIGHT + 100 as Integer;

    onClose: function() {
        java.lang.System.exit( 0 ); 

    scene: Scene {
        fill: Color.WHITE
        content: VBox {
            spacing: 10
            content: [
                view  = MediaView {
                    mediaPlayer: player
                Text {
                    font: Font {
                        size: 24
                    x: 10,
                    y: 30
                    content: bind "{%6s player.currentTime.toString()}"
                HBox {
                    content: [
                        playButton = SwingButton {
                            text: "Play"
                            action: function(): Void {
                                timeSlider.enabled = false;
                        pauseButton = SwingButton {
                            text: "Pause"
                            action: function(): Void {
                                timeSlider.enabled = true;
                        stopButton = SwingButton {
                            text: "Stop"
                            action: function(): Void {
                                player.currentTime = 0s;
                                timeSlider.enabled = true;
                        timeSlider = SwingSlider {
                            minimum: 0
                            maximum: bind
                            media.duration.toMillis() as Integer
                            vertical: false
                            enabled: true
                            value: bind sliderValue with inverse;


System.out.println( "media.width={media.width}" );
System.out.println( "media.height={media.height}" );
System.out.println( "media.duration={media.duration}" );
System.out.println( "player.currentTime={player.currentTime}" );
// End.

Actually the problem is that Java Media Component (JMC) fails to read JAR file type URLs of the type.

generating HTML applet page
Error with Media: MediaError: media Unsupported media: jar:file:/C:/Users/Peter/Documents/NetBeansProjects/FXExamples/trunk/dist/FXExamples.jar!/fxexamples/videos/movie.avi
MediaComponent CREATED
Error with MediaPlayer: MediaError: media Unsupported media: jar:file:/C:/Users/Peter/Documents/NetBeansProjects/FXExamples/trunk/dist/FXExamples.jar!/fxexamples/videos/movie.avi
BUILD SUCCESSFUL (total time: 20 seconds)

Now for a workaround. In your Ant build.xml project file, override the "standard-run" target, so it does not execute against a JAR file, but rather the classes instead. This target works for NetBeans 6.5 until the JavaFX / JMC teams fix the bug.

<target depends="init,compile,jar" description="Run a main class. (PP)" if="standard.execution.trigger" name="standard-run">
        <java classname="${main.class}" classpath="${basedir}/build/compiled:${basedir}/lib/mediacomponent.jar" failonerror="true" fork="true" jvm="${platform.fxhome}/bin/javafx${binary.extension}" jvmargs="${run.jvmargs}"/>


Published at DZone with permission of Peter Pilgrim, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)