1

I am getting this error:

Error: JavaFX runtime components are missing, and are required to run this application

Process finished with exit code 1

I checked multiple solutions on YouTube and StackOverflow such as https://www.youtube.com/watch?v=KKI7tDozPog and Error: JavaFX runtime components are missing, and are required to run this application with JDK 11

As a result, I followed their advice and added what they said to my VM options. This is what I have in my run configuration

enter image description here

Despite this however, I still encountered this error.

enter image description here

Here are some code that I have:

My pom.xml file

<?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>proj4</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>proj4</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <junit.version>5.7.1</junit.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>17-ea+11</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>17-ea+11</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.8.1</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>17</source>
                    <target>17</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.6</version>
                <executions>
                    <execution>
                        <!-- Default configuration for running with: mvn clean javafx:run -->
                        <id>default-cli</id>
                        <configuration>
                            <mainClass>com.example.proj4/application.proj4.PizzeriaApplication</mainClass>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

My application

package application.proj4;

import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.IOException;

public class PizzeriaApplication extends Application
{
    /**
     * This method is the start of the application.
     * @param stage A Stage object
     * @throws IOException An IOException object
     */
    @Override
    public void start(Stage stage) throws IOException
    {
        FXMLLoader fxmlLoader = new FXMLLoader(PizzeriaApplication.class.getResource("pizzeria-view.fxml"));
        Scene scene = new Scene(fxmlLoader.load(), 800, 600);
        stage.setTitle("RU Pizzeria");
        stage.setResizable(false);
        stage.setScene(scene);
        stage.show();

        //This closes the entire application if the Main Menu window is closed
        stage.setOnCloseRequest(t ->
        {
            Platform.exit();
            System.exit(0);
        });
    }

    /**
     * This method launches the application.
     * @param args An array of Strings
     */
    public static void main(String[] args)
    {
        launch();
    }
}

My dependencies in modules of project structure

enter image description here

A response is appreciated.

Josh S.
  • 61
  • 4
  • Within an hour is quick for me I guess. I edited the post though. @ScaryWombat – Josh S. Nov 15 '21 at 01:25
  • 1
    If you put the full error messages formatted as multi-line code text in the question (not as screenshots), as well as the command used to run the app (also formatted as code) it is easier to help troubleshoot issues. – jewelsea Nov 15 '21 at 03:52
  • no screenshots of plain text please – kleopatra Nov 15 '21 at 05:10
  • @jewelsea, I did put the error message as text, it's the first code box. – Josh S. Nov 15 '21 at 15:01
  • But you didn’t put the text of the command used to run the app, which was the crucial thing for being able to understand and answer this question. The full command line is displayed by idea in the [console tab](https://www.jetbrains.com/help/idea/version-control-tool-window-console-tab.html) when you run the program, you can copy text from there, you don’t need to screenshot it and the screenshot does not display the full command line which was used, so it doesn’t help understand or solve the problem. – jewelsea Nov 15 '21 at 16:02
  • @jewelsea I see thank you. – Josh S. Nov 15 '21 at 17:15

1 Answers1

2

Okay, so I found out why this is occurring.

I put the module path and add modules in the program arguments and not in the vm options, which is what is causing the red issue.

Now I am encountering a "Error occurred during initialization of boot layer" issue now.

Josh S.
  • 61
  • 4
  • Suggest you close this question given you have resolved it and post another if you are still having an issue – sprinter Nov 15 '21 at 02:05
  • Unfortunately, I can't resolve my own question with an answer for two days. I also have to wait 90 minutes to post another question. – Josh S. Nov 15 '21 at 02:12
  • You might like to take a look at my answer at https://stackoverflow.com/questions/66630618/intellij-ide-how-to-add-sdk/66630770#66630770 I have found this to be a better way to add JavaFX to a project than altering the VM options - and more in line with the expected use of java modules – sprinter Nov 15 '21 at 02:18
  • Close this question if you found the solution – Harry Coder Nov 15 '21 at 02:32
  • 2
    @HarryCoder No, the question does not need to be closed. It can be [self-answered](https://stackoverflow.com/help/self-answer). And I believe the current self-answer will be useful for future developers who may well experience the same issue. After a couple of days, when the system allows it, the self-answer can be marked correct by Josh S. – jewelsea Nov 15 '21 at 03:34
  • For thee boot layer initialization issue, probably your module path is wrong, see [Error occurred during initialization of boot layer java.lang.module. FindException: Module javafx.controls not found](https://stackoverflow.com/a/66287593/1155209). Looking at the module path used in your question, perhaps it needs to be absolute rather than relative e.g. `/Users/...` instead of `Users/...`. – jewelsea Nov 15 '21 at 03:49