Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-27-2004, 05:39 AM   #1
LQ Newbie
Registered: Apr 2004
Location: India
Posts: 1

Rep: Reputation: 0
Question Exception in thread "main" java.lang.InternalError: Can't connect to X11 window serve

Hello Friends,

I dont know whether this would be the correct forum or not but my problem is very critical so please help me.

1. I am working on linux server where I have installed Tomcat4.x, Apache 2.0, JDK1.4.2. I have set all CLASSPATH.
Java is working fine. I am using one JCLASS component which is useful in chart creation.

3. Few days back the code regarding Frame cration was working fine but now its giving an error. I am actually running these files using cron and my requirement is also same.

4. I have tried almost all possibilities like

export DISPLAY=localhost:0.0
export DISPLAY=ipaddress:0.0, but no luck.

Can you explain me what could be the reason.


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>(
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(
at sun.awt.motif.MToolkit.<clinit>(
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(
at java.awt.Toolkit$
at Method)
at java.awt.Toolkit.getDefaultToolkit(
at java.awt.Toolkit.getEventQueue(
at java.awt.EventQueue.invokeLater(
at javax.swing.SwingUtilities.invokeLater(
at FrameDemo.main(


Please let me know your suggestions as soon aspossible

Last edited by paragvd; 04-27-2004 at 05:54 AM.
Old 04-27-2004, 07:35 AM   #2
Senior Member
Registered: Apr 2003
Location: Eire
Distribution: Slackware 12.0, OpenSuse 10.3
Posts: 1,120

Rep: Reputation: 45
Is it being run as a different user from the one who is currently logged in? If so you may have to incorporate

xhost + localhost

somewhere along the line, I can't try it out at the moment though, running a java gui program from a cron job.
Old 04-27-2004, 05:41 PM   #3
LQ Guru
Registered: Jul 2003
Location: VA
Distribution: Slack 10.1
Posts: 2,194

Rep: Reputation: 47
You will need to make a /etc/X0.hosts file to make the 'xhost' permanent.
Old 08-26-2004, 03:01 AM   #4
LQ Newbie
Registered: Aug 2004
Distribution: debian, suse
Posts: 2

Rep: Reputation: 0
maybe some of you can help me with this:
i know that you have to be logged in as the user who wants to run some gui from the console (after doing that xhost + user or xhost + localhost)
this works fine but if i want to run this scripts with cron, i get errors (cant connect to x server and so on)
but it works fine if i do this by hand
thanx in advance.
Old 10-05-2004, 03:35 AM   #5
LQ Newbie
Registered: Oct 2004
Posts: 1

Rep: Reputation: 0
I had the same problem but found an easy solution elsewhere: use
java -Djava.awt.headless=true ...
to start your software. This will work in Java 1.4 and higher (at least in Sun's own Java, I don't know about other JVM's).

This parameter will make it impossible to actually display anything on a screen, but all the awt stuff which does not really need a screen will work.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot connect to X11 window server using ":).0" as DISPLAY variable cclack Linux - Newbie 4 09-06-2007 09:32 PM
Starting Java from shell script (Exception in thread "main") rolf_mueller Linux - Software 5 10-30-2004 02:11 AM
Java error "Exception in thread "main" java.lang.StackOverflowError" nro Programming 1 09-04-2004 03:47 AM
Exception in thread "main" java.lang.NoClassDefFoundError: Lobais Linux - Software 19 06-23-2004 08:42 AM
Exception in thread "main" java.lang.NoClassDefFoundError: melinda_sayang Programming 2 04-27-2004 11:49 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:03 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration