2
package sample;

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 {

In the above code all javafx are in red, as is Application. Below are the first two of the 13 errors that occur with the javafx sample program (Hello World). (The rest are similar.

Error:(3, 26) java: package javafx.application does not exist
Error:(4, 19) java: package javafx.fxml does not exist

Clearly fixing any one of them is probably going to fix them all.) Everything seems to be fine until I try to run it.

I'm working in IntelliJ 2019.2.4 using SDK 12. (Scenebuilder is installed and seems to work.)

Anybody have a suggestion?

fabian
  • 67,623
  • 12
  • 74
  • 102
  • 1
    is JavaFX installed? I think it is not part of standard Java in newer versions... – user85421 Nov 14 '19 at 16:59
  • Please follow the guide at https://openjfx.io/openjfx-docs/ . – CrazyCoder Nov 14 '19 at 17:02
  • 3
    Confirmed: [Release Notes Java 11](https://www.oracle.com/technetwork/java/javase/11-relnote-issues-5012449.html#JDK-8198527): "JavaFX is no longer included in the JDK. It is now available as a separate download from [openjfx.io](https://openjfx.io/)." – user85421 Nov 14 '19 at 17:05

1 Answers1

5

No longer bundled

JavaFX is no longer bundled with Oracle JDK 11 and later.

JavaFX has never been an official part of Java, as it is not defined in the Java specifications, nor in the JSRs. However, Oracle considers JavaFX to be the successor to Swing, with Swing now in maintenance mode.

FYI, in the past, Oracle was the only vendor that ever bundled JavaFX. If you obtain your Java implementation from any of the other dozen or so vendors, you will add the JavaFX modules to your project. As exceptions to that rule, two vendors now provide an edition of their Java implementations with OpenJFX libraries bundled: LibericaFX from BellSoft, and ZuluFX from Azul Systems.

Available for download

You can choose to download a JavaFX SDK (software development kit). Or you can choose to use the Maven or Gradle dependency management tools to automatically download the necessary modules.

Bookmark the OpenJFX project site. See the Getting Started page.

Further development of JavaFX technology has been open-sourced and spun out of Oracle. Now led by Gluon. Codebase housed as a sub-project known as OpenJFX on the OpenJDK project.


Flowchart guiding you in choosing a vendor for a Java 11 implementation


Motivations in choosing a vendor for Java

Basil Bourque
  • 218,480
  • 72
  • 657
  • 915
  • sir, do you know why oracle prefers to withdraw JavaFX from standards? By the bye, +1 – snr Nov 14 '19 at 17:49
  • @snr Oracle speaks for itself in the linked documents. JavaFX was never standardized. JavaFX was never part of OpenJDK nor included in the [Java specifications](https://docs.oracle.com/javase/specs/). Oracle was the only Java vendor to ever bundle. JavaFX programmers using Java from other vendors have always been adding JavaFX to their projects as a dependency. – Basil Bourque Nov 14 '19 at 18:00
  • 1
    [Liberica JDK distributions](https://bell-sw.com/pages/java-13.0.1/) currently bundle JavaFX in their JDK 13 distribution. It's not a well known distribution and I have never used it, but the bundled installation might be a fairly hassle free installation solution for some who want to just quickly get started developing some simple JavaFX apps. – jewelsea Nov 14 '19 at 19:27
  • 1
    @jewelsea Good to know. By the way, for a list of several vendors of Java builds, see [my Answer](https://stackoverflow.com/a/54737381/642706) with a flowchart I made to help guide your choice of Java providers. – Basil Bourque Nov 14 '19 at 21:20
  • 1
    @jewelsea I have since learned that in addition to BellSoft bundling JavaFX/OpenJFX libraries with Liberica in an edition known as *LibericaFX*, so too Azul Systems bundles the FX libraries wih their Zulu product in an edition known as *ZuluFX*. I have updated my charts to show both. Thanks for your initial tip. – Basil Bourque Jul 20 '20 at 16:27