ubuntu
___@kubuntu:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic
If you put java, it will be like this
___@kubuntu:~$ java --version
opensdk 11.0.1 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)
___@kubuntu:~$ javac --version
javac 11.0.1
As of November 18, 2018, if you install openjdk-11-jdk with apt, openjdk10 will be installed. It seems to switch in the future
This time install java11 using sdkman
The main body of java when installed with sdkman
/home/username/.sdkman/candidates/java/11.0.1-open
It is in
Write the path here when specifying jdk in Intellij etc.
This time I decided to place it in / opt
/opt/openjfx-11.0.1_linux-x64_bin-sdk/
└── javafx-sdk-11.0.1
├── legal
...Abbreviation
└── lib
...Abbreviation
Create a javafx project
How to make it with reference to others
Setting that does not use gradle this time
Write the code appropriately. Some sample is fine
Press [Main ▼] on the upper left to open edit configurations
Write settings such as jdk
Set the VM Option as follows
--module-path=/opt/openjfx-11.0.1_linux-x64_bin-sdk/javafx-sdk-11.0.1/lib
--add-modules=javafx.controls
--add-modules=javafx.swing
--add-modules=javafx.base
--add-modules=javafx.fxml
--add-modules=javafx.media
--add-modules=javafx.web
If you search normally on the net, there are many articles that contain only javafx.controls, which is incomplete, In that state, the following exception will appear, so include all modules
/home/___/.sdkman/candidates/java/11.0.1-open/bin/java -Djava.library.path=/opt/openjfx-11.0.1_linux-x64_bin-sdk/javafx-sdk-11.0.1/lib --module-path=/opt/openjfx-11.0.1_linux-x64_bin-sdk/javafx-sdk-11.0.1/lib --add-modules=javafx.controls -javaagent:/home/___/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/182.5107.16/lib/idea_rt.jar=43339:/home/___/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/182.5107.16/bin -Dfile.encoding=UTF-8 -classpath /home/___/sandbox/javafxtry/out/production/javafxtry:/opt/openjfx-11.0.1_linux-x64_bin-sdk/javafx-sdk-11.0.1/lib/src.zip:/opt/openjfx-11.0.1_linux-x64_bin-sdk/javafx-sdk-11.0.1/lib/javafx-swt.jar:/opt/openjfx-11.0.1_linux-x64_bin-sdk/javafx-sdk-11.0.1/lib/javafx.web.jar:/opt/openjfx-11.0.1_linux-x64_bin-sdk/javafx-sdk-11.0.1/lib/javafx.base.jar:/opt/openjfx-11.0.1_linux-x64_bin-sdk/javafx-sdk-11.0.1/lib/javafx.fxml.jar:/opt/openjfx-11.0.1_linux-x64_bin-sdk/javafx-sdk-11.0.1/lib/javafx.media.jar:/opt/openjfx-11.0.1_linux-x64_bin-sdk/javafx-sdk-11.0.1/lib/javafx.swing.jar:/opt/openjfx-11.0.1_linux-x64_bin-sdk/javafx-sdk-11.0.1/lib/javafx.controls.jar:/opt/openjfx-11.0.1_linux-x64_bin-sdk/javafx-sdk-11.0.1/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 @0x2f837822) 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 @0x2f837822
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.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 sample.Main
Process finished with exit code 1
Recommended Posts