I have tried to open a dialog box in Servlet & it opens fine. But then I tried to achieve same thing in my thread's run method. It gaved me following error:
java.awt.HeadlessException
at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:159)
at java.awt.Window.<init>(Window.java:431)
at java.awt.Frame.<init>(Frame.java:403)
Below is my code :
JFrame frame = new JFrame("Success Message");
frame.setSize(200, 50);
frame.add(new JLabel("Data uploaded from "+inputFile.getFilename()));
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
I also tried below code, but failed
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
System.out.println("Headless mode: " + ge.isHeadless());
if(!ge.isHeadless()){
System.setProperty("java.awt.headless", "true");
}
Exception is described as : Thrown when code that is dependent on a keyboard, display, or mouse is called in an environment that does not support a keyboard, display, or mouse.