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:
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:
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