Reputation: 41
I have been trying to setup my NetBeans 12.4 with JavaFX 16 and it is not working. I have followed the tutorials that I have come across so far on how I might resolve it but with no success so far. I added a global library with the 8 javafx .jar files and removed the src.zip file and the javafx.properties file from the path folder and added the file path to the VM options but it is still throwing up errors.
This is my simple program that throws errors
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaprojectfx;
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.HBox;
import javafx.scene.control.Label;
/**
*
* @author
*/
public class JavaProjectFX extends Application
{
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
launch(args);
}
@Override
public void start(Stage primaryStage)
{
Label messageLabel = new Label("Hello World");
HBox hbox = new HBox(messageLabel);
Scene scene = new Scene(hbox);
primaryStage.setScene(scene);
primaryStage.setTitle("My First GUI Application");
primaryStage.show();
}
}
and this is the error it is giving me
run:
Error occurred during initialization of boot layer
java.lang.module.FindException: Module javafx.base not found
C:\Users\treyh\AppData\Local\NetBeans\Cache\12.4\executor-snippets\run.xml:111: The following error occurred while executing this line:
C:\Users\treyh\AppData\Local\NetBeans\Cache\12.4\executor-snippets\run.xml:68: Java returned: 1
BUILD FAILED (total time: 0 seconds)
this is what I have put in the VM options area in case I wrote it wrong
--module-path "C:\Program Files\Java\javafx-sdk-16\lib" --add-modules=javafx.base,javafx.controls,javafx.fxml,javafx.graphics
Upvotes: 1
Views: 1030
Reputation: 159291
From looking at the JavaFX Getting Started document at openjfx.io, there should not be an =
symbol after add-modules
, just a space, similar to the space after module-path
.
For example:
--module-path "C:\Program Files\Java\javafx-sdk-16\lib" --add-modules javafx.base,javafx.controls,javafx.fxml,javafx.graphics
I think, in your case, you don't need to explicitly add javafx.base,javafx.graphics
as those will be implicitly added as transitive modules when you add javafx.controls,javafx.fxml
. But the additional added modules shouldn't cause any harm either.
Upvotes: 1