1. Richard Bair
  2. fx-games


Clone wiki

fx-games / Setup_a_development_environment

Install the JDK

Download the latest version of the Java Development Kit (JDK) from: http://www.oracle.com/technetwork/java/javase/downloads/index.html

Run the installation - this will include the installation for JavaFX. It can make life easier to install the JDK somewhere easy to remember and access from the command line (I use c:\apps\java).

Once installed, make sure you set your JAVA_HOME to point to the directory you installed Java in, and include JAVA_HOME\bin on your system PATH.

Install Maven

Download the latest version of Maven from: http://maven.apache.org/download.html

Unzip it to somewhere on your local machine that is easy to get to (I use c:\apps\maven). Maven is similar to ANT in that you just need to unzip it, you don't need to install it.

It is a good idea to set a system variable called M2_HOME and then add M2_HOME\bin to your system PATH.

Here is a video walk through for Windows: http://maven.apache.org/download.html More details on installing Maven on Mac and Linux are here: http://www.sonatype.com/books/mvnref-book/reference/installation-sect-maven-install.html

Put JavaFX on your classpath

JavaFX is installed as part of the JDK but it is not made available on the classpath (this will change in a future release soon). You must manually update your JDK to include JavaFX on the path.

The easiest way to do this is to run the following Maven command from anywhere on your classpath:

mvn com.zenjava:javafx-maven-plugin:1.3:fix-classpath

Alternatively, you can manually fix your classpath by copying the jfxrt.jar file from jdk-install-dir\jre\lib to jdk-install-dir\jre\lib\ext. Java will then automatically add this JAR to classpath.

Note: some IDEs (such as NetBeans) may need to be restarted after doing this in order for them to pick up the JavaFX runtime classes.

Get the code

This project is hosted on a Mecurial repository so you need to install a Mecurial tool for your system. Follow the Mecurial steps on the BitBucket help page:

Once you have the Mecurial tool installed you can then 'clone' the code (i.e. download a local copy for editing).

On Windows, open Windows Explorer and browse to a suitable directory that you would like to use for your source code. Right-click on that folder and choose "TortoiseHG -> Clone". In the dialog that pops up enter the repository URL as https://<your-bitbucket-username>@bitbucket.org/rbair/fx-games.

On Mac and Linux use the following command line:

$ hg clone https://<your-bitbucket-username>@bitbucket.org/rbair/fx-games fx-games

Replace <your-bitbucket-username> with your actual username for BitBucket.

It helps to checkout the code to a directory that is easy to remember and access form the command line (I use c:\dev\fxexperience\fx-games).

For more info on using Mecurial see: http://mercurial.selenic.com/wiki/BeginnersGuides

Build and Run

You can optionally use Maven to build and run the project. From a command prompt change directory into the project you checked out and run the following command:

mvn jfx:run

This will compile and run the Defender application.

Setup your IDE

Building and running from the command line is a useful shortcut but generally you will want to build and run from within your IDE. Maven is supported by most popular IDEs, choose the one you like best:

Building a deployment bundle

To build an executable JAR for the Defender application, simply change directory into the defender project and run the following command:

mvn jfx:build-jar

An executable JAR file will be built under the target sub-directory called defender-jfx.jar.

You can also build webstart bundles, and native installers using similar Maven commands. For more information see the JavaFX Maven Plugin homepage: https://github.com/zonski/javafx-maven-plugin/wiki