Java Swing GUI in a Centos 7 Docker container on a Windows Host
NickName:user3641021 Ask DateTime:2021-10-15T01:24:07

Java Swing GUI in a Centos 7 Docker container on a Windows Host

I am building a Docker image FROM centos:7 (I am flexible on the base Linux image) which will run a Java Swing application on a Windows 10 host. When attempting to run the Docker image, I get the following exception:

java.awt.HeadlessException: No X11 DISPLAY variable was set, but this program performed an operation which requires it.
        at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204) ~[?:1.8.0_302]
        at java.awt.Window.<init>(Window.java:536) ~[?:1.8.0_302]
        at java.awt.Frame.<init>(Frame.java:420) ~[?:1.8.0_302]
        at java.awt.Frame.<init>(Frame.java:385) ~[?:1.8.0_302]
        at javax.swing.SwingUtilities$SharedOwnerFrame.<init>(SwingUtilities.java:1763) ~[?:1.8.0_302]
        at javax.swing.SwingUtilities.getSharedOwnerFrame(SwingUtilities.java:1838) ~[?:1.8.0_302]
        at javax.swing.JDialog.<init>(JDialog.java:272) ~[?:1.8.0_302]
        at javax.swing.JDialog.<init>(JDialog.java:206) ~[?:1.8.0_302]

Am I using the wrong Linux flavor or have I not configured it correctly? I would like the resulting image to be standalone and not require any additional software to be installed on the host machine. Is this possible?

Copyright Notice:Content Author:「user3641021」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/69574915/java-swing-gui-in-a-centos-7-docker-container-on-a-windows-host

More about “Java Swing GUI in a Centos 7 Docker container on a Windows Host” related questions