Running JavaFX project on Linux thru Hudson

If you want to get your FX project setup as a Job in Hudson. Simply follow the steps below and victory will be yours!

  • Download the javaFX1.2 SDK installation file for Linux
  • Copy the installation script to the desired locatio
  • Create a new environment variable $JFX_HOME and set it to the base directory of you fx sdk installation
  • Create a simple HelloWorld.fx script and test it’s compiling eg.
  • import javafx.stage.Stage;
    import javafx.scene.Scene;
    import javafx.scene.text.Text;
    import javafx.scene.text.Font;
    
    Stage {
        title: "Application title"
        width: 250
        height: 80
        scene: Scene {
            content: Text {
                font : Font {
                    size : 24
                }
                x: 10, y: 30
                content: "Application content"
            }
        }
    }
    

    Then verify it’s running by executing the javaxc command (much like javac)

  • Add a pom.xml to your project that looks like the one below
  • <build>
    		<sourceDirectory>src</sourceDirectory>
    		<plugins>
    			<plugin>
    				<groupId>org.apache.maven.plugins</groupId>
    				<artifactId>maven-compiler-plugin</artifactId>
    				<configuration>
    					<compilerId>javafxc</compilerId>
    					<include>**/*.fx</include>
    					<fork>true</fork> <!-- NOTE: only “fork” mode supported now -->
    				</configuration>
    				<dependencies>
    					<dependency>
    						<groupId>net.sf.m2-javafxc</groupId>
    						<artifactId>plexus-compiler-javafxc</artifactId>
    						<version>0.3</version> 
    					</dependency>
    				</dependencies>
    			</plugin>
    		</plugins>
    	</build>
    
  • Add a new job in Hudson for a maven2 project and kick off a build. All should be well! If you do get an exception like the one below, then verify your $JFX_HOME variable is set correctly. I had to restart Glassfish in order for Hudosn to pick up the new variable.
  • Caused by: java.lang.NullPointerException
    	at java.io.File.<init>(File.java:222)
    	at net.sf.m2javafxc.javafxc.JavafxcCompiler.compile(JavafxcCompiler.java:146)
    	at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:493)
    	... 32 more