title: Getting a javaFX 11 app to work on docker
body: <p>I am trying to get an application that works perfectly on my machine to run on docker, here is my docker file :</p>
  
  <pre><code>FROM openjdk:11-jre-slim
  VOLUME /tmp
  ADD someJar.jar someJar.jar
  ADD lib lib
  ADD config.properties config.properties
  ENTRYPOINT ["java", "-javaagent:lib/aspectjweaver-1.9.2.jar", 
      "-javaagent:lib/spring-instrument-5.1.6.RELEASE.jar", "--module-path", 
      "lib/javafx-sdk-11.0.2", "--add-modules=javafx.controls", "- 
      Dprism.verbose=true", "-jar","someJar.jar"]
  </code></pre>
  
  <p>I also tried to base it off of the alpine openjdk11 release with the same result :</p>
  
  <pre><code>FROM adoptopenjdk/openjdk11:alpine
  VOLUME /tmp
  RUN apk update &amp;&amp; apk add libx11 mesa-gl gtk+3.0 &amp;&amp; apk update
  ADD someJar.jar someJar.jar
  ADD lib lib
  ADD config.properties config.properties
  ENTRYPOINT ["java", "-javaagent:lib/aspectjweaver-1.9.2.jar", "-javaagent:lib/spring-instrument-5.1.6.RELEASE.jar", "--module-path", "lib", "--add-modules=javafx.controls", "-Dprism.verbose=true", "-jar","someJar.jar"]
  </code></pre>
  
  <p>The lib folder contains the linux flavor of the openJFX runtime (.so files and .jar files).  I am developing this on a Windows machine with the Windows-equivalent of the openJDK runtime and it works perfectly.  When running the container I get the following output :</p>
  
  <pre><code>Prism pipeline init order: es2 sw
  Using Double Precision Marlin Rasterizer
  Using dirty region optimizations
  Not using texture mask for primitives
  Not forcing power of 2 sizes for textures
  Using hardware CLAMP_TO_ZERO mode
  Opting in for HiDPI pixel scaling
  Prism pipeline name = com.sun.prism.es2.ES2Pipeline
  Loading ES2 native library ... prism_es2
  GraphicsPipeline.createPipeline failed for com.sun.prism.es2.ES2Pipeline
  java.lang.UnsatisfiedLinkError: no prism_es2 in java.library.path: [/usr/java/packages/lib, /usr/lib/x86_64-linux-gnu/jni, /lib/x86_64-linux-gnu, /usr/lib/x86_64-linux-gnu, /usr/lib/jni, /lib, /usr/lib]
      at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2660)
      at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:829)
      at java.base/java.lang.System.loadLibrary(System.java:1867)
      at javafx.graphics/com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:150)
      at javafx.graphics/com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:52)
      at javafx.graphics/com.sun.prism.es2.ES2Pipeline.lambda$static$0(ES2Pipeline.java:68)
      at java.base/java.security.AccessController.doPrivileged(Native Method)
      at javafx.graphics/com.sun.prism.es2.ES2Pipeline.&lt;clinit&gt;(ES2Pipeline.java:50)
      at java.base/java.lang.Class.forName0(Native Method)
      at java.base/java.lang.Class.forName(Class.java:315)
      at javafx.graphics/com.sun.prism.GraphicsPipeline.createPipeline(GraphicsPipeline.java:187)
      at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:91)
      at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:124)
      at java.base/java.lang.Thread.run(Thread.java:834)
  *** Fallback to Prism SW pipeline
  Prism pipeline name = com.sun.prism.sw.SWPipeline
  (X) Got class = class com.sun.prism.sw.SWPipeline
  Initialized prism pipeline: com.sun.prism.sw.SWPipeline
  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.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:47)
      at org.springframework.boot.loader.Launcher.launch(Launcher.java:86)
      at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
      at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
  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.&lt;init&gt;(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.launchApplication1(LauncherImpl.java:678)
      at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
      at java.base/java.lang.Thread.run(Thread.java:834)
  </code></pre>
  
  <p>Any idea how i can get a Java app based on OpenJFX11 to work in Docker?</p>
  
  <p>******UPDATE******</p>
  
  <p>I made some progress on this.  I found that putting my openJFX runtime files DIRECTLY in my lib folder made it progress a bit more.  The new error became this:</p>
  
  <pre><code>ImportError: libGL.so.1: cannot open shared object file: No such file or directory
  </code></pre>
  
  <p>After a bit of research, i added this RUN command in my dockerfile :</p>
  
  <pre><code>RUN apt-get update &amp;&amp; apt-get install libgl1-mesa-glx -y
  </code></pre>
  
  <p>This gives me a new stacktrace :</p>
  
  <pre><code>Prism pipeline init order: es2 sw
  Using Double Precision Marlin Rasterizer
  Using dirty region optimizations
  Not using texture mask for primitives
  Not forcing power of 2 sizes for textures
  Using hardware CLAMP_TO_ZERO mode
  Opting in for HiDPI pixel scaling
  Prism pipeline name = com.sun.prism.es2.ES2Pipeline
  Loading ES2 native library ... prism_es2
      succeeded.
  GLFactory using com.sun.prism.es2.X11GLFactory
  (X) Got class = class com.sun.prism.es2.ES2Pipeline
  GraphicsPipeline.createPipeline: error initializing pipeline 
  com.sun.prism.es2.ES2Pipeline
  *** Fallback to Prism SW pipeline
  Prism pipeline name = com.sun.prism.sw.SWPipeline
  (X) Got class = class com.sun.prism.sw.SWPipeline
  Initialized prism pipeline: com.sun.prism.sw.SWPipeline
  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.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:47)
      at org.springframework.boot.loader.Launcher.launch(Launcher.java:86)
      at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
      at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
  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.&lt;init&gt;(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.launchApplication1(LauncherImpl.java:678)
      at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
      at java.base/java.lang.Thread.run(Thread.java:834)
  </code></pre>
  
  <p>******ANOTHER UPDATE******</p>
  
  <p>Digging through the JavaFX code in the GtkApplication.class file, this is the section that is failing :</p>
  
  <pre><code>int libraryToLoad = _queryLibrary(gtkVersion, gtkVersionVerbose);
  
  AccessController.doPrivileged((PrivilegedAction&lt;Void&gt;) () -&gt; {
          if (libraryToLoad == QUERY_NO_DISPLAY) {
              throw new UnsupportedOperationException("Unable to open DISPLAY");
          } else if (libraryToLoad == QUERY_USE_CURRENT) {
              if (gtkVersionVerbose) {
                  System.out.println("Glass GTK library to load is already loaded");
              }
          } else if (libraryToLoad == QUERY_LOAD_GTK2) {
              if (gtkVersionVerbose) {
                  System.out.println("Glass GTK library to load is glassgtk2");
              }
              NativeLibLoader.loadLibrary("glassgtk2");
          } else if (libraryToLoad == QUERY_LOAD_GTK3) {
              if (gtkVersionVerbose) {
                  System.out.println("Glass GTK library to load is glassgtk3");
              }
              NativeLibLoader.loadLibrary("glassgtk3");
          } else {
              throw new UnsupportedOperationException("Internal Error");
          }
          return null;
      });
  </code></pre>
  
  <p>Do i have a missing library or something?</p>
  
  <p>... HELP?</p>
  
  <p>Thanks</p>