1

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...

José Pereda
  • 44,311
  • 7
  • 104
  • 132
Dino Cell
  • 53
  • 8

2 Answers2

0

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.

enveeed
  • 197
  • 2
  • 7
keshav keyal
  • 9
  • 1
  • 3
  • thanks for the answer, but i have already tried this, i downloaded the 38mb zip and put it inside c\programfile\java and then in "project structure" --> modulus i have added it, but still it does not work. any suggestion? (i marked the lib folder inside the javafx-sdk-11 folder) – Dino Cell Oct 19 '18 at 11:48
  • there is no javafx jar file - be precise – kleopatra Oct 20 '18 at 22:15
0

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

Dino Cell
  • 53
  • 8
  • While that might work, that's not the proper solution. See this [answer](https://stackoverflow.com/a/52907749/3956070) on how to solve it. – José Pereda Oct 20 '18 at 16:31