Home > Java > javaTutorial > How to Fix \'IllegalAccessError\' When Creating Labels in JavaFX 11?

How to Fix \'IllegalAccessError\' When Creating Labels in JavaFX 11?

DDD
Release: 2024-10-30 12:10:03
Original
632 people have browsed it

How to Fix

JavaFX 11: IllegalAccessError When Creating Label

This issue arises when attempting to create a JavaFX application with Label in JavaFX 11. The error message, "IllegalAccessError: superclass access check failed," indicates that the class responsible for rendering labels cannot access the superclass for layout helper classes.

To resolve this issue, it's crucial to set the necessary VM options that make JavaFX modules available to the module-path and define the specific modules to be added to your project.

Here's how to configure your IntelliJ Idea for a non-modular JavaFX project:

  1. Navigate to Run -> Edit Configurations.
  2. Add the following VM options:
    -p /usr/lib/jvm/javafx-sdk-11.0.2/lib --add-modules javafx.controls
  3. Click Apply and run your application.

This will make the JavaFX controls module available and resolve the IllegalAccessError, allowing you to create labels in your JavaFX application.

The above is the detailed content of How to Fix 'IllegalAccessError' When Creating Labels in JavaFX 11?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template