1. Richard Bair
  2. fx-games


Clone wiki

fx-games / Setup_IntelliJ_IDEA


Download and install the latest version of IntelliJ IDEA from: http://www.jetbrains.com/idea/download/

Note: the defender game can be built and run with the FREE Community Edition of IntelliJ. You do not need the paid version.

Open the Project

Open IntelliJ and from the quick start dashboard choose Open Project.

Select the pom.xml file in the base directory of the defender project within fx-games that you previously cloned using Mecurial (e.g. your-dev-home\fx-games\defender\pom.xml).

IntelliJ will read the pom.xml file and create a project structure for you. Any third party JARs used by the project will be automatically downloaded and added to the classpath.

Run the Project

To create a Run Profile, select Run -> Edit Configurations

In the dialog that pops up, click the little green plus button on the top right (in previous versions this was yellow plus sign).

From the drop down list, select Application.

Select the main class of com.fxexperience.games.defender.DefenderApp

Leave all other settings as default and click OK. Your Run Configuration is now saved for later use.

To run the project, select Run -> Run and select your Run Configuration from the menu. The Defender application will launch.

Editing and Source Control

To enable Mecurial support in your project select VCS -> Enable Version Control Integration and choose Mecurial from the drop down menu.

Note: if you have not added hg.exe to the system path when installing Mecurial, you will need to first tell IntelliJ where to find it by updating the settings under File -> Settings -> Version Control -> Mecurial

IntelliJ seems to struggle when the project root is not the Mecurial root (as is the case in our defender project). To fix this go to File -> Settings and then choose Version Control.

In the table on the right you will see an entry that has <Project> mapped to Mecurial. You should delete this entry, then add a new one. For the new one select the fx-games directory (i.e. one level up from the defender base directory).

Once this is done IntelliJ will now link your project to the BitBucket Mecurial repository. Edit, add and delete files in your workspace as per normal. When you reach a logical check point in your changes you can "commit" using VCS -> Commit changes. It is good practice to provide a short, meaningful message with your commit to let other users know what you changed.

Committing does not push your changes to the server however, so to share your changes with the rest of the team use VCS -> Mecurial -> Push. All your subsequent commits will then be "pushed" to BitBucket and merged into the main codebase for the rest of the team to use. Use your BitBucket credentials when prompted.

To get the latest changes that other developers have made, use VCS -> Mecurial -> Pull (or CTRL+T). All changes will be downloaded and merged into your local workspace.

For more information on using Mecurial in IntelliJ see: http://www.jetbrains.com/idea/webhelp/using-mercurial-integration.html

Note: do *not* add the IntelliJ project files (i.e. the .iml files and .idea directory to source control). The Maven POM is enough to share configuration.

Maven Tips

You can edit code in the Maven project exactly as you would a normal project, but you should use the Maven directory structure conventions:

  • all Java code should be placed in src\main\java
  • all resources (images, fxml, stylesheets, etc) should be placed in src\main\resources

If you wish to add a third-party library to the project, you simply add the reference to the POM as a dependency. For example, to add the apache-io library to the project you would add the following:


The JAR will then be automatically downloaded and added to the classpath for you and all other developers when next they load the project.

To find dependencies available for download search: http://search.maven.org

For more general information on Maven see: