java 不运行,Java IllegalAccessError无法运行应用程序

在尝试运行JavaFX GUI程序时遇到IllegalAccessError。错误源于com.sun.javafx.fxml.FXMLLoaderHelper无法访问com.sun.javafx.util.Utils。解决方法是在模块路径中添加javafx.controls和javafx.fxml,并确保SDK和项目语言级别的设置正确。同时,检查OpenFX库是否已添加到项目中,并移除不必要的java.awt.*导入。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I'm setting up my first program for a class and I'm stuck on why my program won't run trying to debug. What do I need to do to debug this error?

I've tried to add libraries but this didn't seem to work.

import javafx.event.ActionEvent;

import javafx.event.EventHandler;

import javafx.scene.Parent;

import javafx.scene.Scene;

import java.io.IOException;

import javafx.fxml.FXMLLoader;

import javafx.scene.control.Button;

import javafx.scene.layout.StackPane;

import javafx.stage.Stage;

import java.awt.*;

public class Main extends Application {

@Override

public void start(Stage primaryStage) {

try{

Parent root = FXMLLoader.load(getClass().getResource("Sample.fxml"));

primaryStage.setTitle("My First J

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值