I just switched from Ubuntu 20.04 distro back to Windows with integrated WSL 2, and I am having trouble running my JavaFX project.
I get the following error stacktrace around launch(args)
inside main
method :
hexaquarks@LAPTOP-KPPA3O52:~/Particle_Geometry_Simulation$ cd /home/hexaquarks/Particle_Geometry_Simulation ; /usr/bin/env /usr/lib/jvm/java-11-openjdk-amd64/bin/java --module-path /usr/share/openjfx/lib --add-modules javafx.controls,javafx.fxml,javafx.swing -Dfile.encoding=UTF-8 @/tmp/cp_eiv0idm2cbh7kd2tl4ddw7ff7.argfile AppFrame
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 java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.UnsupportedOperationException: Unable to open DISPLAY
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$new$6(GtkApplication.java:173)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.<init>(GtkApplication.java:171)
at javafx.graphics/com.sun.glass.ui.gtk.GtkPlatformFactory.createApplication(GtkPlatformFactory.java:41)
at javafx.graphics/com.sun.glass.ui.Application.run(Application.java:144)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:258)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:269)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:158)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:409)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
... 5 more
System Configurations
$ java -version
openjdk version "11.0.11" 2021-04-20 OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04)
OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.3 LTS"
$ java -version
openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04)
OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)
Project Tree
$ [.../Particle_Geometry_Simulator] tree
.
├── .vscode
| ├── launch.json
| └── settings.json
├── bin
└── src
├── AppFrame.java
├── ... // f files here
└── ParticleFunJavaFx.fxml
launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Launch AppFrame",
"request": "launch",
"vmArgs": "--module-path /usr/share/openjfx/lib --add-modules javafx.controls,javafx.fxml,javafx.swing",
"mainClass": "AppFrame",
"projectName": "Particle_Geometry_Simulation_4f401646"
},
{
"type": "java",
"name": "Launch Current File",
"request": "launch",
"mainClass": "${file}"
},
{
"type": "java",
"name": "Launch GameFrame",
"request": "launch",
"vmArgs": "--module-path /usr/share/openjfx/lib --add-modules javafx.controls,javafx.fxml,javafx.swing",
"mainClass": "GameFrame",
"projectName": "Particle_Geometry_Simulation_4f401646"
}
]
}
settings.json
{
"java.project.sourcePaths": ["src"],
"java.project.outputPath": "bin",
"java.project.referencedLibraries": [
"lib/**/*.jar",
"/usr/share/openjfx/lib/javafx-swt.jar",
"/usr/share/openjfx/lib/javafx.media.jar",
"/usr/share/openjfx/lib/javafx.web.jar",
"/usr/share/openjfx/lib/javafx.graphics.jar",
"/usr/share/openjfx/lib/javafx.fxml.jar",
"/usr/share/openjfx/lib/javafx.controls.jar",
"/usr/share/openjfx/lib/javafx.base.jar",
"/usr/share/openjfx/lib/javafx.swing.jar"
]
}
Things I have tried
I looked at almost every post on SO regarding this issue with no success.
sudo apt install libgtk-3-0
was not a fix since I had already this installed.
I also tried to delete openjfx
and reinstall it from a different mirror, with no success. Currently the package I have, I have installed it with
sudo apt install openjfx
Does anyone have an idea of what may be going on here ?