Error java: package javafx.application does not exist

Language: Java

java 11.0.9 2020-10-20 LTSJava(TM) SE Runtime Environment 18.9 (build 11.0.9+7-LTS)Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.9+7-LTS, mixed mode)


My Java dir in Program Files

OS: Windows 10

IDE: IntelliJ

IntelliJ IDEA 2020.1.4 (Community Edition)
Build #IC-201.8743.12, built on July 21, 2020
Runtime version: 11.0.7+10-b765.65 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 1964M
Cores: 12

JavaFX Version:


How to get your JavaFX Version:

Look for the file inside the lib directory of your javaFX package you downloaded from the internet:

Heres the webpage I downloaded JavaFX from:

And I don’t usually do this, but I had to download the JavaFX documentation for my specific version (download link at the bottom of the list) because I was seeing so much irrelevant documentation online and because I guess this site expects you to download it. It seems to have a lot of stuff in it I couldn’t find on the website.

You just created a new JavaFX project and there is red text everywhere,

Error messages say something like:

Error java: package javafx.application does not exist

How to fix:

File -> Project Structure

Hit the + button

Navigate to the folder lib folder inside of your javafx-sdk-<version> folder where you have stored all your JavaFX .jar files you should have gotten when you installed the JavaFX SDK,

Mine look like this. I have chosen to copy them into my Java folder in Program Files so that all my Java stuff is in one place,

Make sure you select the “lib” folder

It’ll look like this if you’ve selected correctly

In the Project Explorer on the left side panel it should look like this when you expand External Libraries

There should be a lib folder which when expanded should show you all your jar files

You can see all my red text has disappeared too, so we’re all good to go.

Note: you may need to make sure your VM options are pointed to your JavaFX library as well,

Add a path variable by going to File -> Settings -> Appearance and Behavior -> Path Variables and click the + button to add a new variable you will call “PATH_TO_FX”

Set its value to be the path to the lib folder inside of your JavaFX module you downloaded from the internet,

This is what mine looks like:

go to the Main Selector dropdown on the top right hand side near the Build and Run buttons and select “Edit Configurations …”

And add this line:

--module-path ${PATH_TO_FX} --add-modules javafx.fxml,javafx.controls,

Into the option labelled “VM Options”

I have had serious issues with IntelliJ if I copy and paste into VM Options, even pasting from Sublime Text which is an editor for developers, nothing crazy like Microsoft Word or something, and had issues so I STRONGLY recommend that you actually type that line out instead of copy-pasting it in to VM Options

See VM options (the second item in the form)

Research and Development | Dev Ops | Software Engineer | Topaz Labs

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store