This question already has answers here:
IntelliJ can't recognize JavaFX 11 with OpenJDK 11
(7 answers)
Closed 4 years ago.
i have installed intellij and i'm trying to open a new javafx but i can't manage to run it (even the basic one that is default and should just open a simple window)
i'm using jdk 11(i have to) so i downloaded javafx like said in this post:
Error: JavaFX runtime components are missing, and are required to run this application with JDK 11
but i get this error
"C:\Program Files\Java\jdk-11.0.1\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA
2018.2.5\lib\idea_rt.jar=59874:C:\Program Files\JetBrains\IntelliJ IDEA 2018.2.5\bin" -Dfile.encoding=UTF-8 -classpath "C:\Users\itzik\IdeaProjects\untitled3\out\production\untitled3;C:\Program Files\Java\javafx-sdk-11\lib\src.zip;C:\Program Files\Java\javafx-sdk-11\lib\javafx-swt.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.web.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.base.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.fxml.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.media.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.swing.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.controls.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.graphics.jar" sample.Main
Error: JavaFX runtime components are missing, and are required to run this application
Process finished with exit code 1
and if i try to do this line in solution
then in Run->Edit Configurations -> VM Options, put:
--module-path="C:\Program Files\Java\javafx-sdk-11\lib" --add-modules=javafx.controls
error changes to:
"C:\Program Files\Java\jdk-11.0.1\bin\java.exe" "--module-path=C:\Program Files\Java\javafx-sdk-11\lib"
--add-modules=javafx.controls "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA
2018.2.5\lib\idea_rt.jar=59984:C:\Program Files\JetBrains\IntelliJ IDEA 2018.2.5\bin" -Dfile.encoding=UTF-8 -classpath "C:\Users\itzik\IdeaProjects\untitled3\out\production\untitled3;C:\Program Files\Java\javafx-sdk-11\lib\src.zip;C:\Program Files\Java\javafx-sdk-11\lib\javafx-swt.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.web.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.base.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.fxml.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.media.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.swing.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.controls.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.graphics.jar" sample.Main Exception in Application start method java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464) at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051) Caused by: java.lang.RuntimeException: Exception in Application start method at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900) at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: java.lang.IllegalAccessError: class com.sun.javafx.fxml.FXMLLoaderHelper (in unnamed module #0x555df7da) cannot access class com.sun.javafx.util.Utils (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.util to unnamed module #0x555df7da at com.sun.javafx.fxml.FXMLLoaderHelper.<clinit>(FXMLLoaderHelper.java:38) at javafx.fxml.FXMLLoader.<clinit>(FXMLLoader.java:2056) at sample.Main.start(Main.java:13) at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428) at java.base/java.security.AccessController.doPrivileged(Native Method) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427) at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96) at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174) ... 1 more Exception running application sample.Main
Process finished with exit code 1
i'm trying to fix this problem for over 2 hours searching the web but nothing works =\
tried to set the language level to 8\10\11 in project structure and still doesn't work
regular java program with hello world does work, just java fx does problems...
If you are using JavaFX in Java 11, you need to add the JavaFX jar file.
JavaFX is decoupled with the JDK after JDK 10 so download JavaFX for Java 11 and add it as an external library.
found a solution, in run --> edit configuration ---> VM option
--module-path="C:\Program Files\Java\javafx-sdk-11\lib" --add-modules=javafx.controls --add-exports=javafx.graphics/com.sun.javafx.util=ALL-UNNAMED --add-modules javafx.controls --add-exports=javafx.graphics/com.sun.javafx.util=ALL-UNNAMED --add-exports=javafx.base/com.sun.javafx.reflect=ALL-UNNAMED --add-exports=javafx.base/com.sun.javafx.beans=ALL-UNNAMED --add-exports=javafx.graphics/com.sun.glass.utils=ALL-UNNAMED --add-exports=javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED
Related
Yes, this question has been asked before, but none of the answers provided there solved the issue so:
I'm using ControlsFX 11 on a test project, every time I try to run the project I get this error:
Caused by: java.lang.IllegalAccessError: class org.controlsfx.control.textfield.AutoCompletionBinding (in module org.controlsfx.controls) cannot access class com.sun.javafx.event.EventHandlerManager (in module javafx.base) because module javafx.base does not export com.sun.javafx.event to module org.controlsfx.controls
I tried adding:
--add-exports javafx.base/com.sun.javafx.event=org.controlsfx.controls
And:
--add-exports javafx.base/com.sun.javafx.event=ALL-UNNAMED
Neither of them solved the issue. I'm using IntelliJ IDE and JDK 18.0. This is the full run:
D:\jdk18\bin\java.exe "-javaagent:D:\IntelliJ IDEA 2022.1\lib\idea_rt.jar=53684:D:\IntelliJ IDEA 2022.1\bin" -Dfile.encoding=UTF-8 -classpath "C:\Users\Windows 10\.m2\repository\org\openjfx\javafx-controls\18-ea+6\javafx-controls-18-ea+6.jar;C:\Users\Windows 10\.m2\repository\org\openjfx\javafx-graphics\18-ea+6\javafx-graphics-18-ea+6.jar;C:\Users\Windows 10\.m2\repository\org\openjfx\javafx-base\18-ea+6\javafx-base-18-ea+6.jar;C:\Users\Windows 10\.m2\repository\org\openjfx\javafx-fxml\18-ea+6\javafx-fxml-18-ea+6.jar" -p "C:\Users\Windows 10\.m2\repository\org\openjfx\javafx-fxml\18-ea+6\javafx-fxml-18-ea+6-win.jar;C:\Users\Windows 10\IdeaProjects\test32\controlsfx-11.1.0.jar;C:\Users\Windows 10\IdeaProjects\test32\target\classes;C:\Users\Windows 10\.m2\repository\org\openjfx\javafx-controls\18-ea+6\javafx-controls-18-ea+6-win.jar;C:\Users\Windows 10\.m2\repository\org\openjfx\javafx-base\18-ea+6\javafx-base-18-ea+6-win.jar;C:\Users\Windows 10\.m2\repository\org\openjfx\javafx-graphics\18-ea+6\javafx-graphics-18-ea+6-win.jar" -m com.example.test32/com.example.test32.HelloApplication --add-exports javafx.base/com.sun.javafx.event=org.controlsfx.controls
Exception in Application start method
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:119)
at java.base/java.lang.reflect.Method.invoke(Method.java:577)
at javafx.graphics#18-ea/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:465)
at javafx.graphics#18-ea/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:364)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:577)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1081)
Caused by: java.lang.RuntimeException: Exception in Application start method
at javafx.graphics#18-ea/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:901)
at javafx.graphics#18-ea/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:196)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.IllegalAccessError: class org.controlsfx.control.textfield.AutoCompletionBinding (in module org.controlsfx.controls) cannot access class com.sun.javafx.event.EventHandlerManager (in module javafx.base) because module javafx.base does not export com.sun.javafx.event to module org.controlsfx.controls
at org.controlsfx.controls/org.controlsfx.control.textfield.AutoCompletionBinding.<init>(AutoCompletionBinding.java:538)
at org.controlsfx.controls/impl.org.controlsfx.autocompletion.AutoCompletionTextFieldBinding.<init>(AutoCompletionTextFieldBinding.java:107)
at org.controlsfx.controls/impl.org.controlsfx.autocompletion.AutoCompletionTextFieldBinding.<init>(AutoCompletionTextFieldBinding.java:92)
at org.controlsfx.controls/org.controlsfx.control.textfield.TextFields.bindAutoCompletion(TextFields.java:187)
at org.controlsfx.controls/org.controlsfx.control.textfield.TextFields.bindAutoCompletion(TextFields.java:181)
at com.example.test32/com.example.test32.HelloController.initialize(HelloController.java:25)
at javafx.fxml#18-ea/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2655)
at javafx.fxml#18-ea/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
at javafx.fxml#18-ea/javafx.fxml.FXMLLoader.load(FXMLLoader.java:2516)
at com.example.test32/com.example.test32.HelloApplication.start(HelloApplication.java:14)
at javafx.graphics#18-ea/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
at javafx.graphics#18-ea/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484)
at javafx.graphics#18-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics#18-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
at javafx.graphics#18-ea/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics#18-ea/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics#18-ea/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
... 1 more
Exception running application com.example.test32.HelloApplication
Process finished with exit code 1
So Im having an issue booting up a modded mc server installation using forge 1.12.2.
The reason is unknown but I've had this issue before. All I've heard was to reinstall Java, even though I have done that multiple times.
Here is what my directory looks like:
This is stored inside c:desktop/server. Here is the server boot code: java -Xmx1024M -jar forge-universal.jar nogui.
Here is the error, I cannot understand what any of it means, and there is no offical minecraft crash log:
A problem occurred running the Server launcher.java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.run(ServerLaunchWrapper.java:70)
at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.main(ServerLaunchWrapper.java:34)
Caused by: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')
at net.minecraft.launchwrapper.Launch.<init>(Launch.java:34)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
... 6 more
You seems to be on Java 16. You can check with java -version.
Forge 1.12 can't be runned with this version of Java. So, I suggest you to :
Install older version such as Java 8.
Change boot code to C:\Dir\To\Jre\java.exe -Xmx1024M -jar forge-universal.jar nogui
OR change JAVA_PATH variable to the Java 8 JRE instead of Java 16's one.
I had this working before, and I am 99% positive I have been following the same procedure I have used in the past of adding the lib to the project file structure, adding VM options in the Edit Configurations menu. For some reason I still cannot get JavaFX to work with my setup the way it did in the past. My old projects still run and were written with the same libraries and Java version. I have been banging my head on the wall with this issue all morning, I feel as though the solution may be sitting right in front of me. I have no clue what else to try from here, Reddit has been useless and everything I've searched has been the same.
I have tried running with both, when I took the VM options out the last time I finally got my errors in the editor to go away, but get the errors I had in the original post, this is why I didn't include them in the ZIP but included them in the post.
https://ufile.io/6iknpzqy
I have tried with these VM options and without:
--module-path /home/(myUser)/Downloads/javafx-sdk-15.0.1/lib --add-modules=javafx.controls,javafx.fxml
Exception in Application start method
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: Exception in Application start method
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.IllegalAccessError: superclass access check failed: class com.sun.javafx.scene.control.ControlHelper (in unnamed module #0x34ce8af7) cannot access class com.sun.javafx.scene.layout.RegionHelper (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.scene.layout to unnamed module #0x34ce8af7
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:821)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:719)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:642)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:600)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at javafx.scene.control.Control.<clinit>(Control.java:86)
at DoMath.start(DoMath.java:36)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run$$$capture(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
... 1 more
Exception running application DoMath
Disconnected from the target VM, address: '127.0.0.1:51735', transport: 'socket'
Process finished with exit code 1
Your project is using Java 14, even though you initially specified Java 11 in the question.
Per the documentation when using Java 14 the following VM Options are also needed:
--add-exports javafx.graphics/com.sun.javafx.sg.prism=ALL-UNNAMED
in addition to these options:
--module-path /home/(myUser)/Downloads/javafx-sdk-15.0.1/lib --add-modules=javafx.controls,javafx.fxml
Double check all the options are specified in the VM Options field of the Run Configuration, not in the Program Arguments.
I am trying to run a JavaFX application with OpenJDK/OpenJFX,
this is an existing working application based on OracleJDK/JavaFX which we want to migrate to OpenJFX.
I followed the instructions on how to build a fat jar from the OpenJFX documentation and I use these versions:
OpenJDK 10
OpenJFX 11
I have succesfully built a fat jar that contains all the .class files and libraries.
On Windows 10 I am able to build and run the OpenJFX HelloWorld application. But when running my own application I get errors about various stock shaders that could not be loaded:
java.lang.InternalError: Error loading stock shader Solid_Color
Stacktrace:
java.lang.InternalError: Error loading stock shader Solid_Color
at com.sun.prism.d3d.D3DResourceFactory.createStockShader(D3DResourceFactory.java:411)
at com.sun.prism.impl.ps.BaseShaderContext.getPaintShader(BaseShaderContext.java:263)
at com.sun.prism.impl.ps.BaseShaderContext.validatePaintOp(BaseShaderContext.java:484)
at com.sun.prism.impl.ps.BaseShaderContext.validatePaintOp(BaseShaderContext.java:355)
at com.sun.prism.impl.ps.BaseShaderGraphics.fillQuad(BaseShaderGraphics.java:1613)
at com.sun.javafx.tk.quantum.ViewPainter.doPaint(ViewPainter.java:475)
at com.sun.javafx.tk.quantum.ViewPainter.paintImpl(ViewPainter.java:328)
at com.sun.javafx.tk.quantum.UploadingPainter.run(UploadingPainter.java:142)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:514)
at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
at com.sun.javafx.tk.RenderJob.run(RenderJob.java:58)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
at java.base/java.lang.Thread.run(Thread.java:844)
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at com.sun.prism.d3d.D3DResourceFactory.createStockShader(D3DResourceFactory.java:408)
at com.sun.prism.impl.ps.BaseShaderContext.getPaintShader(BaseShaderContext.java:263)
at com.sun.prism.impl.ps.BaseShaderContext.validatePaintOp(BaseShaderContext.java:484)
at com.sun.prism.impl.ps.BaseShaderContext.validatePaintOp(BaseShaderContext.java:355)
at com.sun.prism.impl.ps.BaseShaderGraphics.fillQuad(BaseShaderGraphics.java:1613)
at com.sun.javafx.tk.quantum.ViewPainter.doPaint(ViewPainter.java:475)
at com.sun.javafx.tk.quantum.ViewPainter.paintImpl(ViewPainter.java:328)
at com.sun.javafx.tk.quantum.UploadingPainter.run(UploadingPainter.java:142)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:514)
at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
at com.sun.javafx.tk.RenderJob.run(RenderJob.java:58)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: java.lang.RuntimeException: InputStream must be non-null
at com.sun.prism.d3d.D3DResourceFactory.getBuffer(D3DResourceFactory.java:349)
at com.sun.prism.d3d.D3DResourceFactory.createShader(D3DResourceFactory.java:390)
at com.sun.prism.shader.Solid_Color_Loader.loadShader(Solid_Color_Loader.java:47)
... 19 more
I followed the suggestion to increase the VRAM from a similar question:
JavaFX on Raspberry PI: Error loading stock shader
This did not help.
Also read another similar question:
How to recompile JavaFX 11/12
Tried to run the application on various Windows installations, same problem.
They seem to be caused by code such as:
Pane root = new Pane();
root.setStyle("-fx-background-color: #676767;-fx-base: #676767; -fx-background: #676767;");
that always worked fine.
What am I missing?
This question already has answers here:
IntelliJ can't recognize JavaFX 11 with OpenJDK 11
(7 answers)
Closed 4 years ago.
I'm running IntelliJ IDEA Ultimate 2018.2.5 with JDK 11.0.1 and JavaFX 11 from OpenJFX. I know it's a common error and I tried many of the proposed fixes but nothing works.
No matter which JavaFX project I try to run I get the error:
Error: JavaFX runtime components are missing, and are required to run this application
If I add the following to the VM options
--module-path="C:\Program Files\Java\javafx-sdk-11\lib" --add-modules=javafx.controls
I get these errors:
Exception in Application start method
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: Exception in Application start method
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.IllegalAccessError: class com.sun.javafx.fxml.FXMLLoaderHelper (in unnamed module #0x5fce9dc5) cannot access class com.sun.javafx.util.Utils (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.util to unnamed module #0x5fce9dc5
at com.sun.javafx.fxml.FXMLLoaderHelper.<clinit>(FXMLLoaderHelper.java:38)
at javafx.fxml.FXMLLoader.<clinit>(FXMLLoader.java:2056)
at sample.Main.start(Main.java:13)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
... 1 more
Exception running application sample.Main
I tried reinstalling without any luck. I have also tried to change
getClass().getResource(...) to getClass().getClassLoader().getResource(...) or to something like Parent root = FXMLLoader.load(getClass().getResource("/sample.fxml")); but still doesn't work.
There are similar questions like this or this other one.
Before JavaFX 11, whenever you were calling something JavaFX related, you had all the javafx modules available within the SDK.
But now you have to include the modules/dependencies you need.
Your error says that you are using FXML but it can't be resolved, but you have just added the javafx.controls module:
--add-modules=javafx.controls
As you can see in the JavaDoc the javafx.controls module depends on javafx.graphics and java.base, but none of those modules includes the FXML classes.
If you need FXML classes like the FXMLLoader, you need to include javafx.fxml module:
--module-path="C:\Program Files\Java\javafx-sdk-11\lib" \
--add-modules=javafx.controls,javafx.fxml
The same will apply if you need media or webkit, those have their own modules.