Hi Brad,
I was relearning Java from the "Java for Python Programmers" book. I experienced an error in this example code with something about the X11 DISPLAY variable. This isn't such a big deal because I understand what the code was supposed to do (based on the explanation afterward) but I am just curious as to what the solution on my end would be. All the info is beneath my signature.
Thank you so much!
-Sri
The issue is under the "Input/ Output/ Scanner" header.
The Example Code:
_________________
import javax.swing.*;
public class TempConvGUI {
public static void main(String[] args) {
String fahrString;
Double fahr, cel;
fahrString = JOptionPane.showInputDialog("Enter the temperature in F");
fahr = new Double(fahrString);
cel = (fahr - 32) * 5.0/9.0;
JOptionPane.showMessageDialog(null,"The temperature in C is, " + cel);
}
}
The Error:
Exception in thread "main" java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
at java.desktop/java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:208)
at java.desktop/java.awt.Window.(Window.java:548)
at java.desktop/java.awt.Frame.(Frame.java:423)
at java.desktop/java.awt.Frame.(Frame.java:388)
at java.desktop/javax.swing.SwingUtilities$SharedOwnerFrame.(SwingUtilities.java:1919)
at java.desktop/javax.swing.SwingUtilities.getSharedOwnerFrame(SwingUtilities.java:1995)
at java.desktop/javax.swing.JOptionPane.getRootFrame(JOptionPane.java:1689)
at java.desktop/javax.swing.JOptionPane.showInputDialog(JOptionPane.java:580)
at java.desktop/javax.swing.JOptionPane.showInputDialog(JOptionPane.java:527)
at java.desktop/javax.swing.JOptionPane.showInputDialog(JOptionPane.java:475)
at java.desktop/javax.swing.JOptionPane.showInputDialog(JOptionPane.java:439)
at TempConvGUI.main(TempConvGUI.java:9)