【问题标题】:Netbeans 12.4 setup of JavaFX not working keep throwing Error occurred initialization of boot layerJavaFX 的 Netbeans 12.4 设置不工作继续抛出错误发生启动层初始化
【发布时间】:2021-10-13 14:41:47
【问题描述】:

我一直在尝试使用 JavaFX 16 设置我的 NetBeans 12.4,但它无法正常工作。到目前为止,我已经按照我遇到的关于如何解决它的教程进行操作,但到目前为止还没有成功。我添加了一个包含 8 个 javafx .jar 文件的全局库,并从路径文件夹中删除了 src.zip 文件和 javafx.properties 文件,并将文件路径添加到 VM 选项中,但它仍然抛出错误。

这是我抛出错误的简单程序

/*
 * 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();
    }   
}

这是它给我的错误

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)

这是我在虚拟机选项区域中输入的内容,以防我写错了

--module-path "C:\Program Files\Java\javafx-sdk-16\lib" --add-modules=javafx.base,javafx.controls,javafx.fxml,javafx.graphics

【问题讨论】:

    标签: java javafx netbeans


    【解决方案1】:

    从openjfx.io的JavaFX Getting Started document看,add-modules后面不应该有=符号,只是一个空格,类似于module-path后面的空格。

    例如:

    --module-path "C:\Program Files\Java\javafx-sdk-16\lib" --add-modules javafx.base,javafx.controls,javafx.fxml,javafx.graphics

    我认为,在您的情况下,您不需要显式添加javafx.base,javafx.graphics,因为当您添加javafx.controls,javafx.fxml 时,它们将被隐式添加为传递模块。但是额外添加的模块也不应该造成任何伤害。

    【讨论】:

      猜你喜欢
      • 2020-06-24
      • 2021-05-17
      • 2019-02-24
      • 1970-01-01
      • 2021-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多