title: Running Java Swing GUI application on Docker
body: <p>I am trying to run a custom java swing GUI using the docker toolbox in windows.
  I want to now containerize this application however getting following error:</p>
  
  <pre><code>Exception in thread "main" java.lang.UnsatisfiedLinkError: 
  /opt/jdk1.8.0_202/jre
  /lib/amd64/libawt_xawt.so: libXext.so.6: cannot open shared object file: 
  No such file or directory
  </code></pre>
  
  <p>I am running a dockerfile.
  The setup is:</p>
  
  <blockquote>
    <p>1) Install Linux  </p>
    
    <p>2) Install JDK</p>
    
    <p>3) Copy over the folder containing
    the JAR </p>
    
    <p>4) run the docker container which would bring up the GUI ( not
    the linux front-end , not using a vnc is preferred).</p>
  </blockquote>
  
  <p>I am using <em>Xlaunch</em> for the terminal on windows and am able to launch a firefox on docker using this.</p>
  
  <h1>This is the first docker file</h1>
  
  <pre><code>FROM anapsix/alpine-java
  COPY ./myJarFolder /home/myJarFolder
  CMD ["java","-jar","/home/myJarFolder/myJarFile.jar"]
  </code></pre>
  
  <h1>This is the second docker file</h1>
  
  <pre><code>FROM alpine:3.2
  
  MAINTAINER Anastas Dancha [...]
  
  # Install cURL
  
  RUN apk --no-cache add ca-certificates
  
  # Java Version
  
  ENV JAVA_VERSION_MAJOR 8
  
  ENV JAVA_VERSION_MINOR 45
  
  ENV JAVA_VERSION_BUILD 14
  
  ENV JAVA_PACKAGE       jdk
  
  # Download and unarchive Java
  
  RUN mkdir /opt &amp;&amp; / curl -jksSLH "Cookie: oraclelicense=accept-securebackup-cookie" &amp;&amp; / http://download.oracle.com/otn-pub/java/jdk/${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-b${JAVA_VERSION_BUILD}/${JAVA_PACKAGE}-${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-linux-x64.tar.gz | tar -xzf - -C /opt &amp;&amp; / ln -s /opt/jdk1.${JAVA_VERSION_MAJOR}.0_${JAVA_VERSION_MINOR} /opt/jdk &amp;&amp; / rm -rf /opt/jdk/*src.zip &amp;&amp; /opt/jdk/lib/missioncontrol &amp;&amp; /opt/jdk/lib/visualvm &amp;&amp; /opt/jdk/lib/*javafx* &amp;&amp; /opt/jdk/jre/lib/plugin.jar &amp;&amp; /opt/jdk/jre/lib/ext/jfxrt.jar &amp;&amp; /opt/jdk/jre/bin/javaws &amp;&amp; /opt/jdk/jre/lib/javaws.jar &amp;&amp; /opt/jdk/jre/lib/desktop &amp;&amp; /opt/jdk/jre/plugin &amp;&amp; /opt/jdk/jre/lib/deploy* &amp;&amp; /opt/jdk/jre/lib/*javafx* &amp;&amp; /opt/jdk/jre/lib/*jfx* &amp;&amp; /opt/jdk/jre/lib/amd64/libdecora_sse.so &amp;&amp; /opt/jdk/jre/lib/amd64/libprism_*.so &amp;&amp; /opt/jdk/jre/lib/amd64/libfxplugins.so &amp;&amp; /opt/jdk/jre/lib/amd64/libglass.so &amp;&amp; /opt/jdk/jre/lib/amd64/libgstreamer-lite.so &amp;&amp; /opt/jdk/jre/lib/amd64/libjavafx*.so &amp;&amp;    /opt/jdk/jre/lib/amd64/libjfx*.so
  
  # Set environment
  
  ENV JAVA_HOME /opt/jdk
  
  ENV PATH ${PATH}:${JAVA_HOME}/bin   
  
  # COPY myJarFolder from local repository to the image
  
  COPY ./myJarFolder /usr/local/myJarFolder 
  
  # Start the image with the jar file as the entrypoint
  
  ENTRYPOINT ["java", "-jar", "usr/local/myJarFolder/myJarFile.jar"]
  
  # EOF
  </code></pre>
  
  <h1>I am getting this error with the first dockerfile</h1>
  
  <blockquote>
    <p>$ docker run -ti --rm -e DISPLAY=10.193.146.124:0.0 myDocker:1.0
    Exception in thread "main" java.lang.UnsatisfiedLinkError:
    /opt/jdk1.8.0_202/jre /lib/amd64/libawt_xawt.so: libXext.so.6: cannot
    open shared object file: No such  file or directory
            at java.lang.ClassLoader$NativeLibrary.load(Native Method)
            at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
            at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
            at java.lang.Runtime.load0(Runtime.java:809)
            at java.lang.System.load(System.java:1086)
            at java.lang.ClassLoader$NativeLibrary.load(Native Method)
            at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
            at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1845)
            at java.lang.Runtime.loadLibrary0(Runtime.java:870)
            at java.lang.System.loadLibrary(System.java:1122)
            at java.awt.Toolkit$3.run(Toolkit.java:1636)
            at java.awt.Toolkit$3.run(Toolkit.java:1634)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.awt.Toolkit.loadLibraries(Toolkit.java:1633)
            at java.awt.Toolkit.(Toolkit.java:1670)
            at java.awt.Component.(Component.java:593)
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Class.java:348)
            at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
    der.java:56)</p>
  </blockquote>
  
  <p>I am getting <em>permission error</em> with the <strong>second dockerfile</strong> at <em>mkdir /opt</em> line.</p>
  
  <p>Can someone please let me know the correct way of doing it in windows.</p>