Issue
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 href="https://www.youtube.com/watch?v=KKI7tDozPog" rel="nofollow noreferrer">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
Despite this however, I still encountered this error.
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
A response is appreciated.
Solution
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.
Answered By - Josh S.
Answer Checked By - Marie Seifert (JavaFixing Admin)