-2

enter image description here

When I try to run the java swing image getting the "Headless Exception error"

DockerFile:

FROM openjdk:8

COPY requiredlibararies requiredlibraries

COPY myjar.jar myjar.jar CMD ["java", "-Djava.awt.headless=true", "-jar", "myjar.jar"]

Hari Raj
  • 3
  • 5

1 Answers1

0

The container has to interact with the Mouse Keyboard and display of the your host machine to execute the GUI. Installed X11 server on the host machine and then communicated the container with the x11 server of my host machine.

  1. Installed vcxsrv-64.1.20.8.1.installer
  2. Started the Xlaunch
  3. docker run -it --rm -e DISPLAY=${ipaddress of hostmachine} image/bin/bash
Hari Raj
  • 3
  • 5
  • Note that X11 security is an afterthought, and if you can do this, you have it most likely turned it off. Be absolutely certain that vcxsrv is not listening on a port exposed to others (configure your firewall and/or vcxsrv) or anyone can point to your machineand do nasty stuff. – Thorbjørn Ravn Andersen Dec 23 '20 at 13:58