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.
Related
I am trying to create a jar file for a Groovy program I have written (BINSIC - an interpreter cum DSL that runs BASIC code: https://github.com/mcmenaminadrian/BINSIC).
I have a fundamental problem in that the code runs fine (if very slowly) on the development machine but fails on deployment (see below) - even on a box where I have installed a full Groovy installation. It looks like I'm failing to import something into the jar which is then called, though I don't know why that would fail when I have a full Groovy install. I have had the same problem with several different versions of Java (also using sdkman) activated.
What do I have to do to get the code to work on deployment? Does anyone know?
Setting groovy 3.0.2 as default.
lorraine#Kobani:~/Downloads$ java -jar binsic.jar test.bas
Exception in thread "main" 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 org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61)
Caused by: java.lang.NoClassDefFoundError: Unable to load class org.apache.groovy.jaxb.extensions.JaxbExtensions due to missing dependency javax/xml/bind/JAXBContext
at org.codehaus.groovy.vmplugin.v8.Java8.configureClassNode(Java8.java:458)
at org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:274)
at org.codehaus.groovy.ast.ClassNode.getMethods(ClassNode.java:396)
at org.codehaus.groovy.transform.stc.AbstractExtensionMethodCache.scan(AbstractExtensionMethodCache.java:116)
at org.codehaus.groovy.transform.stc.AbstractExtensionMethodCache.getMethods(AbstractExtensionMethodCache.java:97)
at org.codehaus.groovy.transform.stc.AbstractExtensionMethodCache.getMethodsFromClassLoader(AbstractExtensionMethodCache.java:73)
at org.codehaus.groovy.runtime.memoize.StampedCommonCache.compute(StampedCommonCache.java:163)
at org.codehaus.groovy.runtime.memoize.StampedCommonCache.getAndPut(StampedCommonCache.java:154)
at org.codehaus.groovy.runtime.memoize.StampedCommonCache.getAndPut(StampedCommonCache.java:115)
at org.codehaus.groovy.transform.stc.AbstractExtensionMethodCache.get(AbstractExtensionMethodCache.java:51)
at org.codehaus.groovy.macro.transform.MacroCallTransformingVisitor.findMacroMethods(MacroCallTransformingVisitor.java:119)
at org.codehaus.groovy.macro.transform.MacroCallTransformingVisitor.visitMethodCallExpression(MacroCallTransformingVisitor.java:90)
at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:76)
at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:117)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:200)
at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40)
at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:86)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:164)
at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)
at org.codehaus.groovy.ast.MethodCallTransformation.visit(MethodCallTransformation.java:42)
at org.codehaus.groovy.transform.ASTTransformationVisitor.lambda$addPhaseOperationsForGlobalTransforms$4(ASTTransformationVisitor.java:336)
at org.codehaus.groovy.control.CompilationUnit$ISourceUnitOperation.doPhaseOperation(CompilationUnit.java:880)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:650)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:627)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:389)
at groovy.lang.GroovyClassLoader.lambda$parseClass$3(GroovyClassLoader.java:332)
at org.codehaus.groovy.runtime.memoize.StampedCommonCache.compute(StampedCommonCache.java:163)
at org.codehaus.groovy.runtime.memoize.StampedCommonCache.getAndPut(StampedCommonCache.java:154)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:330)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:530)
at groovy.lang.GroovyShell.parse(GroovyShell.java:542)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:430)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:474)
at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:274)
at binsic.BinsicEngine.process(Binsic.groovy:53)
at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:274)
at binsic.Binsic.run(Binsic.groovy:81)
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 org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1262)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1029)
at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:1027)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:1010)
at org.codehaus.groovy.runtime.InvokerHelper.runScript(InvokerHelper.java:442)
at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:274)
at binsic.Binsic.main(Binsic.groovy)
... 5 more
the root error message:
Caused by: java.lang.NoClassDefFoundError:
Unable to load class org.apache.groovy.jaxb.extensions.JaxbExtensions
due to
missing dependency javax/xml/bind/JAXBContext
open site https://search.maven.org/
and search for full class name that s missing with prefix fc:
like this fc:javax.xml.bind.JAXBContext
https://search.maven.org/search?q=fc:javax.xml.bind.JAXBContext
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:567)
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:567)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.IllegalAccessError: class MainFile.Main (in unnamed module #0x234bef66) cannot access class com.sun.javafx.application.LauncherImpl (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.application to unnamed module #0x234bef66
at MainFile.Main.main(Main.java:100)
... 11 more
Exception running application MainFile.Main
This is the exception that I am getting and I know for a fact that it is not with the problem of the code and this has something to do with IntelliJ but I don't know what should I do to fix this.
Some possible approaches that I found can perhaps work
1) VM Option in the Configuration
2) add-export
Please let me know how I might be able to solve this problem. Thanks in advance!
You have at least two options:
Add a VM argument to export the needed package to your code. Since your code is in the unnamed module, such an argument would look like:
--add-exports javafx.graphics/com.sun.javafx.application=ALL-UNNAMED
Note: Replace ALL-UNNAMED with your module's name if and when you make your code modular.
Where you add this argument depends on how you're application is being launched. You have to ensure your application uses that argument when being compiled and executed, including after deployment.
Set the javafx.preloader system property before launching the application and stop using LauncherImpl altogether. This can be done on the command line:
-Djavafx.preloader=com.example.PreloaderImpl
Or in the main method:
public static void main(String[] args) {
System.setProperty("javafx.preloader", PreloaderImpl.class.getName());
Application.launch(ApplicationImpl.class, args);
}
The second option is probably the easier to implement of the two.
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 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
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.