Sep 222011

I have created a simple Maven archetype for building standalone JavaFX 2.0 applications written in Scala. The generated Scala code is a close translation of the Java code for the Colorful Circles demo in Oracle’s Getting Started with JavaFX tutorial. Here’s how it looks:


You need to have the following installed:

  1. JDK 1.6 or later.
  2. JavaFX 2.0 SDK Beta or later.
  3. Maven 3.0.3 or later.

Obviously, using an IDE is a nice option, for example NetBeans 7.0.1.


Before you can use a generated project you need to set the environment variable JAVAFX_HOME to the sub-directory bin of the installation directory for JavaFX 2.0 SKD. For example:

C:Program FilesOracleJavaFX 2.0 SDKbin

Setting the environment variable to this sub-directory has the additional benefit that it makes the javafxpackager utility work as designed, even though this utility is not used by the generated project.


Now use your favorite IDE to generate a project from the Maven archetype with the coordinates:

GroupId: de.schlichtherle
ArtifactId: javafx-scala-demo
Version: 0.3

If you’re not using an IDE, then run maven from a shell as follows:

$ mvn archetype:generate -Dfilter=de.schlichtherle:javafx-scala-demo

When prompted, select the latest version and answer the next prompts for the GroupId, ArtifactId, Version and Package Name for the generated project.


Now you can use your IDE to open the generated project directory. If you are using NetBeans, just press the “run” button to watch Maven building and running the demo application.

If you’re not using an IDE, then change to the generated project directory and enter the following to build the demo application:

$ mvn install

To run the demo application, enter the following:

$ java -jar target/*-jar-with-dependencies.jar


  3 Responses to “A Maven archetype for JavaFX 2.0 in Scala”

  1. Hi Christian,
    I would be interested in seeing how you, in general, would interface with JavaFX from Scala.
    But, before I start installing Maven and all this, would it be possible to please just get a pasted document of parts of your source-code, to have a look at?

    Thank you and cheers,

  2. […] Christian Schlichtherle has blogged about a Maven archetype for JavaFX 2.0 in Scala. […]

Sorry, the comment form is closed at this time.