Dr. Vatsal Shah
Subject Material

Java · JavaFX · Topic 2

How to Set Up JavaFX Using Eclipse and IntelliJ IDEA

Choose Eclipse or IntelliJ IDEA and follow a separate, complete setup path for JDK 27, JavaFX 27, Scene Builder, FXML, and a working Windows application.

Choose one setup path

Eclipse or IntelliJ IDEA

Each tab is independent. Follow only the instructions for the IDE you use.

Eclipse Setup

Track progress · 1 of 12 sections

Step 1 of 12

2.1 Recommended Downloads

Learning objective

Download each required component from its official publisher.

Check your understanding: Which JavaFX download contains the lib folder needed by Eclipse?

The Windows x64 JavaFX SDK ZIP.

Step 2 of 12

2.2 Install JDK 27

Learning objective

Install the Java development kit and verify both runtime and compiler commands.

Installation steps

  • Download the Windows x64 .exe installer from the official JDK card.
  • Double-click the installer and complete the wizard.
  • Open Command Prompt after installation.
  • Run both verification commands shown below.
Command Prompt
java -version
javac -version
Check your understanding: Which two commands verify that the runtime and compiler are available?

java -version and javac -version.

Step 3 of 12

2.3 Install Eclipse

Learning objective

Install and open the Java Developers edition of Eclipse.

Installation steps

  • Download Eclipse from the official Eclipse card.
  • Run the Eclipse Installer.
  • Select Eclipse IDE for Java Developers.
  • Choose an installation directory and finish installation.
  • Launch Eclipse and select a workspace folder.
Check your understanding: Which Eclipse package should students select?

Eclipse IDE for Java Developers.

Step 4 of 12

2.4 Install e(fx)clipse

Learning objective

Add JavaFX-aware tooling to Eclipse through Marketplace.

Marketplace steps

  • Open Eclipse.
  • Select Help → Eclipse Marketplace…
  • Search for e(fx)clipse.
  • Find the JavaFX tooling package and click Install.
  • Accept the prompts and restart Eclipse.
  • After restarting, verify that JavaFX-related tooling is available.
Check your understanding: Does e(fx)clipse replace the JavaFX SDK?

No. It adds IDE tooling; students must also download and configure the JavaFX SDK.

Step 5 of 12

2.5 Install Scene Builder

Learning objective

Install the visual FXML editor and verify that it opens.

Installation steps

  • Download the Windows .msi installer from the official Scene Builder card.
  • Double-click the installer and complete the wizard.
  • Open Scene Builder from the Windows Start menu.
  • Verify that the application launches.
Check your understanding: What kind of file does Scene Builder save for the JavaFX interface?

An FXML file.

Step 6 of 12

2.6 Register JDK 27 in Eclipse

Learning objective

Configure Eclipse to use the installed JDK rather than an older runtime.

Eclipse configuration

  • Go to Window → Preferences → Java → Installed JREs.
  • Click Add → Standard VM → Next.
  • Browse to the JDK 27 installation directory.
  • Click Finish.
  • Select JDK 27 as the default.
  • Click Apply and Close.
Check your understanding: Should Eclipse be pointed to the JDK root or its bin folder?

The JDK root directory, not the bin folder.

Step 7 of 12

2.7 Extract and Configure JavaFX 27

Learning objective

Create an Eclipse User Library from every JAR in the JavaFX SDK lib folder.

SDK and User Library steps

  • Download the Windows x64 JavaFX SDK ZIP.
  • Extract it to a permanent folder such as C:\Java\javafx-sdk-27.0.1.
  • In Eclipse, open Window → Preferences → Java → Build Path → User Libraries.
  • Click New… and enter JavaFX27.
  • Select JavaFX27 and click Add External JARs….
  • Open the extracted SDK lib directory, select all .jar files, and click Open.
  • Click Apply and Close.
Expected SDK folder structure
C:\Java\javafx-sdk-27.0.1
    └── lib
        ├── javafx.base.jar
        ├── javafx.controls.jar
        ├── javafx.fxml.jar
        ├── javafx.graphics.jar
        └── ...
Check your understanding: Which SDK folder contains the JavaFX JAR files?

The lib folder.

Step 8 of 12

2.8 Configure Scene Builder in Eclipse

Learning objective

Connect Eclipse JavaFX tooling to Scene Builder and the JavaFX SDK.

Preference settings

  • Open Window → Preferences → JavaFX.
  • Set the Scene Builder executable to the installed SceneBuilder.exe.
  • If available, set JavaFX 11+ SDK to the JavaFX SDK root directory.
  • Click Apply and Close.
Check your understanding: When Eclipse requests the JavaFX SDK root, should you select lib?

No. Select the folder that contains lib.

Step 9 of 12

2.9 Create a JavaFX Project

Learning objective

Create a simple non-modular Java project and attach the JavaFX27 library.

Project steps

  • Select File → New → Java Project.
  • Enter StudentFX as the project name.
  • Select JDK 27 as the project JRE.
  • Finish the project and leave module-info.java unchecked if prompted.
  • Right-click the project → Properties → Java Build Path → Libraries.
  • Add the JavaFX27 User Library and configure its JavaFX JARs consistently on the Modulepath.
  • Confirm that the project uses JDK 27.
Check your understanding: Should module-info.java be created for this introductory project?

No. Leave it unchecked for this non-modular project.

Step 10 of 12

2.10 Configure VM Arguments

Learning objective

Tell the Java launcher where the JavaFX modules are located and which modules to enable.

Run configuration steps

  • Select Run → Run Configurations….
  • Choose Java Application and create or select the configuration for the main class.
  • On the JRE tab, select JDK 27.
  • Open the Arguments tab.
  • Paste the VM arguments shown below.
  • Leave Program arguments empty and click Apply.
VM arguments
--module-path "C:\Java\javafx-sdk-27.0.1\lib" --add-modules javafx.controls,javafx.fxml --enable-native-access=javafx.graphics
Check your understanding: Where are these options entered in Eclipse?

Run Configurations → Java Application → Arguments → VM arguments.

Step 11 of 12

2.11 Create Main.java and MainView.fxml

Learning objective

Build a complete JavaFX program that loads an FXML layout.

Create the files

  • Under src, create a package named application.
  • Create Main.java inside the package.
  • Create MainView.fxml inside the same package.
  • Open MainView.fxml with Scene Builder using Open With → Scene Builder, or open it directly in Scene Builder.
  • Save the FXML file after designing the interface.
Main.java
package application;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class Main extends Application {
    @Override
    public void start(Stage stage) throws Exception {
        Parent root = FXMLLoader.load(
                getClass().getResource("MainView.fxml"));
        stage.setTitle("StudentFX");
        stage.setScene(new Scene(root, 420, 220));
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
MainView.fxml
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.VBox?>

<VBox alignment="CENTER" spacing="14.0"
      xmlns="http://javafx.com/javafx/27"
      xmlns:fx="http://javafx.com/fxml/1">
    <padding><Insets top="24" right="24" bottom="24" left="24"/></padding>
    <Label text="JavaFX is configured successfully!"/>
    <Button text="Ready to Learn"/>
</VBox>
Check your understanding: Which class loads an FXML file?

FXMLLoader.

Step 12 of 12

2.12 Run and Verify the Application

Learning objective

Launch the program and diagnose the result using a final checklist.

Run the application

  • Save Main.java and MainView.fxml.
  • Ensure Main.java loads MainView.fxml using FXMLLoader.
  • Right-click Main.java → Run As → Java Application.
  • Verify that the designed window and controls appear.
Expected result
// Run application.Main using the configured VM arguments.
// The interface is loaded from MainView.fxml.
Visual result
A 420 x 220 window opens.
Title: StudentFX
Content: "JavaFX is configured successfully!"
Button: "Ready to Learn"
Check your understanding: What visible result proves that JavaFX and FXML are configured correctly?

The StudentFX window opens and displays the controls defined in MainView.fxml.

IntelliJ IDEA Setup

Track progress · 1 of 12 sections

Step 1 of 12

2.1 Recommended Downloads

Learning objective

Download the IntelliJ setup components only from their official publishers.

Check your understanding: Does IntelliJ IDEA include JavaFX in JDK 27?

No. JavaFX is configured separately; Maven can download its libraries for the project.

Step 2 of 12

2.2 Install and Verify JDK 27

Learning objective

Install Oracle JDK 27 and confirm that both Java commands are available.

Installation steps

  • Download the Windows x64 .exe installer from the JDK 27 row.
  • Run the installer and complete its wizard.
  • Open a new Command Prompt window.
  • Run both commands shown below.
Command Prompt
java -version
javac -version
Check your understanding: Which commands verify the JDK installation?

java -version and javac -version.

Step 3 of 12

2.3 Install IntelliJ IDEA

Learning objective

Install the current IntelliJ IDEA release and create a workspace for JavaFX projects.

Installation steps

  • Open the official IntelliJ IDEA download page.
  • Download the Windows installer.
  • Run it and accept the recommended launcher and file-association options.
  • Start IntelliJ IDEA.
  • Complete the first-run prompts and choose a project directory.
Check your understanding: Which IntelliJ edition is required for these JavaFX lessons?

The current unified IntelliJ IDEA installer provides the required core Java features.

Step 4 of 12

2.4 Verify JavaFX Support

Learning objective

Confirm that IntelliJ JavaFX support is enabled before creating the project.

Plugin check

  • Open File → Settings, or press Ctrl+Alt+S.
  • Select Plugins → Installed.
  • Search for JavaFX.
  • Enable the bundled JavaFX plugin if it is disabled.
  • Restart IntelliJ IDEA if requested.
Check your understanding: Does the IntelliJ JavaFX plugin replace the JavaFX dependencies?

No. The plugin provides IDE tooling; Maven provides the libraries used to build and run.

Step 5 of 12

2.5 Install Scene Builder 26.0.0

Learning objective

Install and test the standalone visual editor used for FXML layouts.

Installation steps

  • Open the official Scene Builder download page.
  • Choose the Windows Installer (.msi) for Scene Builder 26.0.0.
  • Run the installer and finish the wizard.
  • Launch Scene Builder once from the Start menu.
  • Close it after confirming that the design window opens.
Check your understanding: What does Scene Builder save?

It saves the visual interface as an FXML file.

Step 6 of 12

2.6 Connect Scene Builder to IntelliJ IDEA

Learning objective

Register the actual SceneBuilder.exe location so FXML files can open visually.

Configuration steps

  • Open File → Settings.
  • Select Languages & Frameworks → JavaFX.
  • Beside Path to SceneBuilder, browse to the installed SceneBuilder.exe.
  • Click Apply and OK.
  • Later, right-click an FXML file and choose Open In SceneBuilder, or use the Scene Builder editor tab when available.
Common Windows location
C:\Users\<YourUserName>\AppData\Local\SceneBuilder\SceneBuilder.exe
Check your understanding: Where is the Scene Builder path configured?

File → Settings → Languages & Frameworks → JavaFX.

Step 7 of 12

2.7 Create a Maven JavaFX Project

Learning objective

Create an IntelliJ Maven project that uses JDK 27.

New project steps

  • On the Welcome screen, click New Project, or choose File → New → Project.
  • Select Java and choose Maven as the build system.
  • Name the project JavaFXStudentDemo.
  • Choose JDK 27 as the Project SDK.
  • Set Group to com.example and Artifact to javafx-student-demo.
  • Create the project and wait for Maven import to finish.
Check your understanding: Why is Maven used in this IntelliJ setup?

It downloads and manages the JavaFX libraries and provides a repeatable run command.

Step 8 of 12

2.8 Configure pom.xml for JavaFX 27

Learning objective

Declare JavaFX Controls, FXML, Java 27 compilation, and the JavaFX Maven launcher.

pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>javafx-student-demo</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <maven.compiler.release>27</maven.compiler.release>
        <javafx.version>27.0.1</javafx.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>${javafx.version}</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>${javafx.version}</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.14.1</version>
                <configuration><release>27</release></configuration>
            </plugin>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.8</version>
                <configuration><mainClass>com.example.Main</mainClass></configuration>
            </plugin>
        </plugins>
    </build>
</project>

After saving

  • Click the Maven reload icon when IntelliJ displays it.
  • Wait until dependency downloads finish.
  • Open the Maven tool window and confirm that the project has no red dependency errors.
Check your understanding: Which two JavaFX modules are required by this FXML example?

javafx-controls and javafx-fxml.

Step 9 of 12

2.9 Create the Java and FXML Files

Learning objective

Place Java classes and FXML resources in the standard Maven folders.

Project structure
JavaFXStudentDemo
├── pom.xml
└── src/main
    ├── java/com/example
    │   ├── Main.java
    │   └── MainController.java
    └── resources/com/example
        └── MainView.fxml
Main.java
package com.example;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class Main extends Application {
    @Override
    public void start(Stage stage) throws Exception {
        FXMLLoader loader = new FXMLLoader(
                Main.class.getResource("MainView.fxml"));
        Scene scene = new Scene(loader.load(), 600, 400);
        stage.setTitle("JavaFX Student Demo");
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
MainController.java
package com.example;

import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;

public class MainController {
    @FXML private TextField txtName;
    @FXML private Label lblMessage;

    @FXML
    private void handleClick() {
        String name = txtName.getText().trim();
        lblMessage.setText(name.isEmpty()
                ? "Please enter your name."
                : "Welcome, " + name + "!");
    }
}
Check your understanding: Where should MainView.fxml be stored?

src/main/resources/com/example/MainView.fxml.

Step 10 of 12

2.10 Design MainView.fxml

Learning objective

Create the visual layout and connect it to MainController.

MainView.fxml
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.VBox?>

<VBox xmlns="http://javafx.com/javafx/27"
      xmlns:fx="http://javafx.com/fxml/1"
      fx:controller="com.example.MainController"
      alignment="CENTER" spacing="15">
    <padding><Insets top="24" right="24" bottom="24" left="24"/></padding>
    <Label text="JavaFX with IntelliJ IDEA"/>
    <TextField fx:id="txtName" promptText="Enter your name" maxWidth="240"/>
    <Button text="Show Message" onAction="#handleClick"/>
    <Label fx:id="lblMessage"/>
</VBox>

Open it visually

  • Right-click MainView.fxml in the Project panel.
  • Choose Open In SceneBuilder, or select the Scene Builder editor tab if shown.
  • Drag or arrange the controls.
  • Keep Controller class as com.example.MainController.
  • Save the FXML file before returning to IntelliJ.
Check your understanding: Which FXML attribute connects the root layout to MainController?

fx:controller="com.example.MainController".

Step 11 of 12

2.11 Run the IntelliJ Application

Learning objective

Run the Maven-configured program and verify the interactive result.

Run from IntelliJ

  • Open the Maven tool window.
  • Expand Plugins → javafx.
  • Double-click javafx:run.
  • Alternatively, open IntelliJ Terminal and run the command below.
  • Wait for the JavaFX window to appear.
IntelliJ Terminal
mvn clean javafx:run
Expected result
// Enter "Vatsal" and click Show Message.
Visual result
A 600 x 400 window opens.
Title: JavaFX Student Demo
Input: Vatsal
Message: Welcome, Vatsal!
Check your understanding: Which Maven command launches this JavaFX project?

mvn clean javafx:run.

Step 12 of 12

2.12 Troubleshoot the IntelliJ Setup

Learning objective

Identify common Maven, FXML, controller, and Scene Builder configuration errors.

Common errors
ErrorLikely causeSolution
JavaFX runtime components are missingThe Maven run configuration was bypassedRun Maven javafx:run and confirm the plugin mainClass.
Location is requiredFXML resource path or filename is wrongPlace MainView.fxml under src/main/resources/com/example and match the case exactly.
No controller specifiedFXML has handlers but no controllerSet fx:controller="com.example.MainController" on the root.
Controller method not foundonAction name differs from the methodMatch #handleClick with an @FXML handleClick() method.
Scene Builder does not openExecutable path is missing or incorrectSelect the actual SceneBuilder.exe in IntelliJ JavaFX settings.
Maven dependencies unresolvedImport or download did not completeReload the Maven project and inspect the Maven error output.

Final checklist

  • Project SDK is JDK 27.
  • pom.xml uses compiler release 27 and JavaFX 27.0.1.
  • Main.java and MainController.java are under src/main/java/com/example.
  • MainView.fxml is under src/main/resources/com/example.
  • The FXML controller and event handler names match the Java class.
  • Scene Builder points to the installed executable.
  • mvn clean javafx:run opens the window.
Check your understanding: What should be checked first when FXMLLoader reports Location is required?

Check that MainView.fxml is in src/main/resources/com/example and that its name matches getResource().