I am using java 1.7.0_67 on mac osx 10.7.5. Here is my hello world gui:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class helloWorld extends JFrame {
helloWorld(String title) {
this.setSize(500,500);
setTitle(title);
}
public static void main(String[] args) {
helloWorld window = new helloWorld("Helloworld");
window.setVisible(true);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
This runs just fine when i open a mac terminal and type java helloWorld
. However, when I ssh into my mac from another host, set my DISPLAY
env variable, and run, I get the following exception:
Exception in thread "main" java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
at java.awt.GraphicsEnvironment.checkedHeadless(GraphicsEnvironment.java:207)
at java.awt.Window.<init>(Window.java:535)
at java.awt.Frame.<init>(Frame.java:420)
at java.awt.Frame.<init>(Frame.java:385)
at javax.swing.JFrame.<init>(JFrame.java:180)
at helloWorld.<init>(helloWorld.java:8)
at helloWorld.main(helloWorld.java:14)
This used to work on Java 1.6, from what I've been able to research this appears to be a purposeful break.
Any ideas how I can get my gui to display after ssh-ing in from a remote host? I don't want to use X11 (would prefer native gui rendering).