1

I tried a simple java program to show dialog box. It's working in Windows systems.

package test;

import javax.swing.JOptionPane;

public class JPane {
    public static void main(String[] args) {
        int dialogButton = JOptionPane.YES_NO_OPTION;
        int dialogResult = JOptionPane.showConfirmDialog (null, "Would You Like to Save your Previous Note First?","warning",dialogButton,JOptionPane.WARNING_MESSAGE);
        if(dialogResult == JOptionPane.YES_OPTION){
            System.out.println("Yes");
        }
        else
            System.out.println("No");
    }
}

But when i tried the same code in unix environment it's showing 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:207) at java.awt.Window.(Window.java:535) at java.awt.Frame.(Frame.java:420) at java.awt.Frame.(Frame.java:385) at javax.swing.SwingUtilities$SharedOwnerFrame.(SwingUtilities.java:1759)

I tried setting DISPLAY env variable through putty. But still same exception.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
shiva
  • 59
  • 1
  • 3
  • 7

0 Answers0