my dog learned polymorphism*
The moose likes Swing / AWT / SWT and the fly likes Run AWT program on Linux from telnet!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Run AWT program on Linux from telnet!!!" Watch "Run AWT program on Linux from telnet!!!" New topic
Author

Run AWT program on Linux from telnet!!!

James wu
Greenhorn

Joined: Feb 20, 2001
Posts: 5
Hi,
I need your help! What I want to do is that my Java program is running on Linux and called from telnet. The program will just draw some charts and save them as PNG file by using a pure java PNG encoder, WITHOUT displaying. But when I run it using telnet, I got this:
Exception in thread "main" java.lang.InternalError: Can't connect to X11 window
server using ':0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:5
8)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:120)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvi
ronment.java:58)
at java.awt.Font.initializeFont(Font.java:264)
at java.awt.Font.<init>(Font.java:298)
at SCTester.<clinit>(SCTester.java:30)
But if I run it from a X window on linux it will be ok. Is there any way that can help me to run my program from telnet. I am not good at linux and x server, so i do need your help! Thanks
J
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
This is a well-known problem with Java on Linux. The graphics subsysystem in the JRE stupidly assumes that there is an X-Windows system running on the system which it can use for things like allocating image buffers.
There are two types of fix. You can either install an X-Windows simulator such as xvfb (look up xvfb in any good search engine, or you may have it already) or a replacement graphics subsystem such as PJA (from http://www.eteks.com/pja/en/ ).


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Run AWT program on Linux from telnet!!!
 
Similar Threads
JFreeChart / X11 window server error
how to run an application in unix and display in windows
XWindows error
how to use x11 to run the window java program?
error while using BufferedImage class in servlet