Error: JavaFX Runtime Components Are Missing, And Are Required To Run This Application With JDK 11

To resolve the error "JavaFX runtime components are missing" when running an application with JDK 11, you need to follow these steps:

  1. Install the JavaFX SDK: Download the JavaFX SDK from the official website: https://openjfx.io/. Make sure to select the version that matches your JDK version (e.g., JDK 11.0.2 or JDK 11.0.11).

  2. Extract the JavaFX SDK: Extract the downloaded JavaFX SDK to a preferred location on your computer.

  3. Set the JavaFX SDK path: Set the JavaFX SDK path as an environment variable. Open your terminal or command prompt and run the following command (Note: Replace path_to_javafx_sdk with the actual path where you extracted the JavaFX SDK):

    • On macOS/Linux:

      export PATH_TO_JAVAFX=path_to_javafx_sdk
      export PATH=$PATH:$PATH_TO_JAVAFX/lib
      
    • On Windows:

      setx PATH_TO_JAVAFX "path_to_javafx_sdk"
      setx PATH "%PATH%;%PATH_TO_JAVAFX%\lib"
      
  4. Update your Java command: Modify the command you use to run your Java program by adding the --module-path and --add-modules options. Also, remember to replace MainClass with the actual name of your main class:

    • On macOS/Linux:

      java --module-path $PATH_TO_JAVAFX --add-modules javafx.controls,javafx.fxml MainClass
      
    • On Windows:

      java --module-path %PATH_TO_JAVAFX% --add-modules javafx.controls,javafx.fxml MainClass
      

Ensure you’ve correctly followed these steps, and then run your Java application again. It should now work without the JavaFX runtime components missing error.

About the Author Rex

I'm a passionate tech blogger with an insatiable love for programming! From my early days tinkering with code, I've delved into web dev, mobile apps, and AI. Sharing insights and tutorials with the world is my joy, connecting me to a global community of like-minded tech enthusiasts. Python holds a special place in my heart, but I embrace all challenges. Constantly learning, I attend tech conferences, contribute to open-source projects, and engage in code review sessions. My ultimate goal is to inspire the next generation of developers and contribute positively to the ever-evolving tech landscape. Let's code together!