Installing Java, JavaFX, and IntelliJ IDEA

Getting The Java Development System

Download the Java SDK (Software Development Kit) from You have to accept the license.

Install it.

Enabling Command-Line Compilation and Execution

Extra step (detailed instructions not included): Set up your PATH environment variable to include the JDK binaries directory. If you have a Linux or MacOS computer, installing the JDK automatically sets the PATH so that you have access to Java command line tools.

If you have a Windows computer without the WSL (Windows Subsystem for Linux) or you did not install Java on that subsystem, you have to modify your PATH environment variable yourself. Some fairly recent instructions can be found here.

Make sure that the commands
    java -version
    javac -version
work and display the version of Java you expect (11.x in spring 2019).

Install IntelliJ IDEA

For IntelliJ IDEA you need a free student account. If you don't already have one from having used PyCharm, go to and sign up.

Download IntelliJ IDEA from

Install it.

Download JavaFX Library

Download JavaFX from Get the SDK, not the "jmods".

Some IntelliJ IDEA setup instructions are at, however we have some below as well.

Accessing Java and JavaFX from the Command Line

Throughout these instructions, substitute for "jfxdir" the directory (folder) where you placed the JavaFX jar files. Here is where it is on the CS department lab computers.

Linux (ICL1, ICL2, queeg, glados)
MacOS (ICL5)
(You may have to hit Command+Shift+G in the file chooser to see this directory.)
Windows (ICL6)

How to Compile and Run from the Command Line (For Windows, you must have set up your PATH environment variable.)

$ ls jfxdir # Windows command would be "dir jfxdir"
javafx-swt.jar		javafx.web.jar		libjfxmedia.dylib
javafx.base.jar		libdecora_sse.dylib	libjfxmedia_avf.dylib
javafx.controls.jar	libfxplugins.dylib	libjfxwebkit.dylib
javafx.fxml.jar		libglass.dylib		libprism_common.dylib	libglib-lite.dylib	libprism_es2.dylib	libgstreamer-lite.dylib	libprism_sw.dylib	libjavafx_font.dylib
javafx.swing.jar	libjavafx_iio.dylib

$ javac --module-path jfxdir --add-modules=javafx.controls your-source-files

$ java --module-path jfxdir --add-modules=javafx.controls your-main-class-file


$ javac --module-path jfxdir --add-modules=ALL-MODULE-PATH your-source-files

$ java --module-path jfxdir --add-modules=ALL-MODULE-PATH your-main-class-file

IntelliJ IDEA One-Time Setup

Run IntelliJ IDEA. Note that if you installed Java in the standard location, the tool should find it. If as you follow the steps below, you are told that the Java compiler, or Java runtime, cannot be found, try these locations or ask for help if it's your own computer.

Linux (ICL1, ICL2, queeg, glados)
MacOS (ICL5)
(You may have to hit Command+Shift+G in the file chooser to see this directory.)
Windows (ICL6)
C:\Program Files\Java\jdk-11.0.1

Throughout these instructions, substitute for "jfxdir" the directory where you placed the JavaFx jar files.

At the startup screen (no project open)...

In Configure → Project Defaults → Project Structure, add the jfxdir directory to Global Libraries using the "+" button at the top.

Creating a Project

The following is what you must do for every project that uses JavaFX. For now, to test things, make a project called "Lab00".

Do not put all your labs into one IntelliJ project. Make a new one each time!

Choose Create New Project from the initial screen.

In the dialog that follows, make sure plain Java is selcected on the left and that the Project SDK is the version of Java you downloaded. Change it if you have to.

Hit Next, but don't check any templates.

Hit Next, and choose a project name. Afterwards, but before you close the dialog window, if you don't like where the tool is saving your projects, change the directory.

Advice: Never change the lowest level directory name. It should match your project name.

Within the specific project:

FileProject Structure
    Project SettingsModules

Select the Dependencies tab. Look for the +/- buttons, near the bottom, in that section. Hit the + button, choose Libraries, and navigate to and choose your jfxdir directory. If you did the earlier steps correctly, it should be listed under Global Libraries. Check the box next to the newly added JavaFX library location. Hit OK.

If not already opened, open up the Project tab on the left edge of the tool window.

Open the directory for the project ("Lab00" for this example).

Select the src directory.

Right-click and make a NewJava Class called HelloFX.

Paste this code into it, replacing any text the tool placed in there:

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class HelloFX extends Application {

    public void start( Stage stage ) {
        String javaVersion = System.getProperty( "java.version" );
        String javafxVersion = System.getProperty( "javafx.version" );
        Label l = new Label(
                        "Hello, JavaFX " + javafxVersion +
                        ", running on Java " + javaVersion + "."
        Scene scene = new Scene( new StackPane( l ), 640, 480 );
        stage.setScene( scene );;

    public static void main( String[] args ) {


To run your program you need a run configuration. There is an Add Configuration button at the top of the tool window. Click it.

In the dialog, click "+" to make a new configuration. Select Application from the list.

Choose a good name. (In the future, you may have more than one run configuration for a project. But for this example, calling it plain old "HelloFX" is fine.)

Set the Main class. For the example, it is HelloFX (not "" or "HelloFX.class").

Add these VM arguments: --module-path jfxdir --add-modules=javafx.controls (Don't forget to substitute your directory for "jfxdir".)

(We are not sure if we'll need other modules, but if so this may be simpler:
--module-path jfxdir --add-modules=ALL-MODULE-PATH

Note: The run configuration dialog might display your main class as erroneous. It may just be that the tool doesn't like classes that are not in packages. It will still run.

Click "OK".

The name of the configuration you just made should now be showing in the button that used to say "Add Configuration". (In the future, you can click the adjacent pull-down menu and select "Edit Configurations" to add, remove, or change run configurations.)

Click the above-described button.

If everything is correct, your program should compile and a big window should pop up that displays the version of Java you are running. If this does not happen, seek help.

You should also see that the program is running by the fact that the small square at the top of the tool window has turned red. (Clicking that square when it is red is an emergency way to stop your program.)

Hit the OS-supplied app-closing button in the frame of the window. (It is typically red.)

The program should terminate, and the square's red color should go away.

Multiple Run Configurations in One Project

If you are planning on trying out lots of little JavaFX applications from within a single IntelliJ IDEA project, you may find this useful.

  1. Open the "Edit Configurations" dialog (e.g. Run → Edit Configurations…).
  2. Click the arrow next to the Wrench icon in the pane on the left to expand it.
  3. Click "Application".
  4. Paste your VM options into the field on the right.
    (e.g. --module-path C:\Users\Snoopy\javafx-sdk-11.0.1\lib --add-modules=ALL-MODULE-PATH).
  5. Click the OK button.

This will update the Application template for this project only so that the specified VM arguments are used any time you create a new run configuration that uses the "Application" template. This includes any configurations created by right-clicking on a class and running from the pop-up menu.

This will make your life a little easier because you won't need to copy/paste the VM arguments for every configuration.