I have a GUI applicationwith javafx on a jar file which runs perfectly on my pc on ubuntu 18.10 with openjdk8 and openjfx installed.
But when I do the same on Docker with my Dockerfile like this:
FROM openjdk:8-jdk
RUN apt-get update && apt-get install -y --no-install-recommends openjfx && rm -rf /var/lib/apt/lists/*
ADD myapp.jar myapp.jar
CMD java -jar myapp.jar
Then building (successfully) and running it with those commands:
docker build -t app1 .
docker run app1
It shows me the following error:
Error: Could not find or load main class application.Sample
I tried every forum on the subject but I still cannot understand where this error comes from. Can someone help me with this ?
EDIT: I just changed my Dockerfile, which looks like this now:
FROM ubuntu
RUN apt-get update && apt-get install -y openjdk-11-jdk
RUN apt-get update && apt-get install -y --no-install-recommends openjfx && rm -rf /var/lib/apt/lists/*
ADD myapp.jar myapp.jar
CMD java -jar myapp.jar
I built and ran it with same commands and now I'm getting this error:
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.RuntimeException: java.lang.UnsatisfiedLinkError: com.sun.glass.ui.gtk.GtkApplication._isDisplayValid()Z
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:268)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:269)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:158)
at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:678)
at 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.UnsatisfiedLinkError: com.sun.glass.ui.gtk.GtkApplication._isDisplayValid()Z
at com.sun.glass.ui.gtk.GtkApplication._isDisplayValid(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.isDisplayValid(GtkApplication.java:83)
at com.sun.glass.ui.gtk.GtkApplication.<init>(GtkApplication.java:67)
at com.sun.glass.ui.gtk.GtkPlatformFactory.createApplication(GtkPlatformFactory.java:41)
at com.sun.glass.ui.Application.run(Application.java:144)
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:258)
... 6 more
My application should display a window when it runs. I read somewhere that docker cannot do this. Is it true ?