diff --git a/core-java-modules/core-java-jar/src/main/java/com/baeldung/jar/MySampleGUIAppn.java b/core-java-modules/core-java-jar/src/main/java/com/baeldung/jar/MySampleGUIAppn.java index cc0a161d0f..2be8cef717 100644 --- a/core-java-modules/core-java-jar/src/main/java/com/baeldung/jar/MySampleGUIAppn.java +++ b/core-java-modules/core-java-jar/src/main/java/com/baeldung/jar/MySampleGUIAppn.java @@ -12,7 +12,9 @@ public class MySampleGUIAppn extends JFrame{ Button b = new Button("Click Me!"); b.setBounds(30,100,80,30); add(b); - setVisible(true); + if (!GraphicsEnvironment.isHeadless()) { + setVisible(true); + } addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { dispose();