Where to put --enable-native-access=javafx.graphics

Answered

Been a few years since I built a Java GUI project.

Using comm edition. Watched a video to start up a JavaFx project and got this:

WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::load has been called by com.sun.glass.utils.NativeLibLoader in module javafx.graphics (file:/C:/Users/Storm/.m2/repository/org/openjfx/javafx-graphics/17.0.6/javafx-graphics-17.0.6-win.jar)
WARNING: Use --enable-native-access=javafx.graphics to avoid a warning for callers in this module
WARNING: Restricted methods will be blocked in a future release unless native access is enabled

WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::allocateMemory has been called by com.sun.marlin.OffHeapArray (file:/C:/Users/Storm/.m2/repository/org/openjfx/javafx-graphics/17.0.6/javafx-graphics-17.0.6-win.jar)
WARNING: Please consider reporting this to the maintainers of class com.sun.marlin.OffHeapArray
WARNING: sun.misc.Unsafe::allocateMemory will be removed in a future release

Just installed this:

IntelliJ IDEA 2024.3.5 (Community Edition)
Build #IC-243.26053.27, built on March 15, 2025
Runtime version: 21.0.6+8-b631.39 amd64 (JCEF 122.1.9)
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Toolkit: sun.awt.windows.WToolkit
Windows 11.0
GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation
Memory: 2048M
Cores: 24
Registry:
 ide.experimental.ui=true
 llm.show.ai.promotion.window.on.start=false
Kotlin: 243.26053.27-IJ
 

So. I'd love to clean up these warnings. 

(1) I have no idea where to paste in the --enable…yadayadayada Some settings I'm guessing, but not clear where. Can't find project settings that looks like the place.

(2) No clue how to fix the second one. That looks like JavaFx is just not compatible with 

I installed Java 1.8 x64 on Win 11 before I started. Not sure that's interesting.
I'm looking for then OpenSDK version… Oh here is something:

IMPLEMENTOR="Oracle Corporation"
JAVA_RUNTIME_VERSION="24+36-3646"
JAVA_VERSION="24"
JAVA_VERSION_DATE="2025-03-18"

So could someone point me to answers for (1) and (2) above?

BTW - I did some research and looks like (2) is being taken care of recently by developers.

Thx

0
4 comments

I'll see if I get errors using Vaadin Flow.

LOL

Actually, no. Apparently JavaFx is the way to go since Vaadin requires a web browser to run on a desktop. So I gather than swing is old and crufty. JavaFx is the best way currently to build a Desktop app. Oracle is apparently trying to offload it to a new owner, but Vaadin is not a suitable replacement.

Correct?

0

It should be specified in the VM Options:

 

For JavaFX specific questions, please use resources like https://stackoverflow.com/ .

 

1

Oh, JavaFX can be a bit tricky to get going sometimes! It's good you're sharing your experience with that `enable-native-access` warning. It helps others know they're not alone if they hit that too. Hope you figure it out!

0

Got this same error and this helped me fix it :D

But now when I run from maven ( mvn javafx:run, mvn clean javafx:run or mvn javafx:jlink(though jlink is a completely different issue)), it happens as well. 

And for now I have the doubt of whether adding it in vm in runner under maven setting would work… 

*Well I ended up adding it to Maven settings>Runner: environment variables 

0

Please sign in to leave a comment.