2

I am using a Raspberry Pi 2 model with Debian as the OS. I tried a simple java swing program that opens a JFrame on it, and it worked fine.

Later, I wanted to use my Pi headlessly i.e. without connecting Display, keyboard and mouse. So I connected to it using the Ethernet port. I installed the tight VNC server on the Pi and the VNC viewer client on my desktop PC.

I was able to view and operate the Pi's desktop from my PC, but when I tried to run the same Java swing program, it exited giving out Java Headless exception and sometimes an authentication error. After searching on the Internet I tried some export DISPLAY commands, but no use.

I understand that I need to set some parameters, either relating to the JRE or the operating system.

Below is the stack

pi@raspberrypi:~/prog $ sudo java HelloSwing

Client is not authorized to connect to ServerException in thread "main" java.awt.AWTError: Can't connect to X11 window server using ':1.0' as the value of the DISPLAY variable.

at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)

at sun.awt.X11GraphicsEnvironment.access$200(X11GraphicsEnvironment.java:65)

at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:115)

at java.security.AccessController.doPrivileged(Native Method)

at sun.awt.X11GraphicsEnvironment.(X11GraphicsEnvironment.java:74)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:259)

at java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:102)

at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:81)

at java.awt.Window.initGC(Window.java:475)

at java.awt.Window.init(Window.java:495)

at java.awt.Window.(Window.java:537)

at java.awt.Frame.(Frame.java:420)

at javax.swing.JFrame.(JFrame.java:225)

at HelloSwing.main(HelloSwing.java:6)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.