X11 problem in Linux - Pl Help

A discussion forum for the JCommon class library.
Post Reply
Posts: 1
Joined: Tue Apr 24, 2007 9:56 pm

X11 problem in Linux - Pl Help

Post by rohit.jyotika » Tue Apr 24, 2007 10:06 pm


I am getting the X11 Display 0.0 error.
If I set the java.awt.headless property to true I get a different error - java.lang.NoClassDefFoundError (Stack Trace below).
I created a test jsp to test this out. The line with the Font gives this error.Can someone help me out.

Java Version - 1.4.1
Tomcat 5.5 on Linux

out.println("<br>Headless Property set");
System.setProperty("java.awt.headless", "true");
out.println("<br>Setting Color");
java.awt.Color color = java.awt.Color.BLUE;
out.println("<br>Color set...Setting Font");
java.awt.Font font = new java.awt.Font("Arial", java.awt.Font.BOLD, 12);
out.println("<br>Font Set");

Stack Trace:
java.lang.Class.forName0(Native Method)

JFreeReport Project Leader
Posts: 698
Joined: Fri Mar 14, 2003 3:34 pm

Post by Taqua » Tue Apr 24, 2007 10:18 pm

Beginner's mistake: The system property must be set *outside* of Java. Set it in your tomcat's startup script instead (catalina.sh, if I remember right.)


The AWT is initialized during the system startup. At the point where you set your system-property, the AWT is already up and running (or crashed already), and so it is way to late to try to fix it. The only safe way to tell the AWT how to behave is to define the system property when the VM starts up, which means, you have to declare the property as command-line option (using 'java -Djava.awt.headless=true ..' as command line).

Have fun,
said Thomas

Posts: 16
Joined: Mon Apr 30, 2007 4:03 am

Still Problem

Post by yongheo » Wed Jul 04, 2007 6:20 am

Dear Taqua,

I still got the exception problem.
I'm using linux (Fedora Core 6) at the moment.
The same source code works fine at Window but I can't get it work at linux box.

Code: Select all

[yong@localhost bin]$ java -Djava.awt.headless=true Main
Exception in thread "main" java.awt.HeadlessException
        at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:159)
        at java.awt.Window.<init>(Window.java:317)
        at java.awt.Frame.<init>(Frame.java:419)
        at javax.swing.JFrame.<init>(JFrame.java:194)
        at Main.main(Main.java:18)
I was looking for solution for doing this. And I havn't found step by step solution yet.
I'm using JDK1.5. Is this a problem?
Is there any easier way to enable running Jfreechart application on Linux?


JFreeReport Project Leader
Posts: 698
Joined: Fri Mar 14, 2003 3:34 pm

Post by Taqua » Wed Jul 04, 2007 12:32 pm

Well, thats simple:

You are now in headless mode (which tells the JDK, that you dont have an X11-Server running and that you DO NOT WANT A GUI), and therefore creating a Frame or Dialog is impossible. If you write a web-application, how should a user click buttons on a Frame (that pops up on the server) from his remote machine.

If - however - you *want a Swing-GUI* then well, do not use the Headless mode. But in that case, you need a X11-Server up and running.

Have fun,
said Thomas

Posts: 16
Joined: Mon Apr 30, 2007 4:03 am


Post by yongheo » Fri Jul 06, 2007 2:52 am

Dear Taqua

I'm new to linux environment.
Everything was okay till I use window. Now I need to run linux and
I found that so many problems occur including applet, jdk, x11 ..etc.
I have vnc server and I also I x11-server I think.
Could you be able to tell me more detail hot wo run them and use them?
I do want to use jfreechart on linux box.

Thanks in advance.


Post Reply