• Post Reply Bookmark Topic Watch Topic
  • New Topic

XWindows error  RSS feed

 
Sham Jowsaki
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I was trying to access a image file in my java program, am getting the following error
can you pls advise me how to solve this
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:126)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:130)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:62)
at sun.awt.motif.MToolkit.<clinit>(MToolkit.java:70)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:130)
at java.awt.Toolkit$2.run(Toolkit.java:712)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:703)

Tks
Cheers
jowsaki
 
stephen Kang
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your error message looks your process doesn't have right access permission using your java application.
thus, when you simply run jre, it violates Xwindow DISPLAY, which is good for the security reason,anyways.
Assume you don't have access root permission in your home directory on bash shell.
type
$ whoami
=>i_user
$ echo $DISPALY
=>:0.0
$ su -
=>passwd:
#whoami
=>root
#DISPLAY=:0.0
#export DISPALY
#echo $DISPALY
=>:0.0
#cd ~i_user/$JAVA_HOME/bin <-- assume u have JAVA_HOME variable on your .bashrc, otherwise you can go to that directory .e.g) /usr/java/j2sdk_1.4.1_02

it will fix your problem.
the difference of command 'su' and 'su -' are you can use root's enviroment variable on your user X windows.
check out man for 'su'.
hope that it will help.
[ March 11, 2003: Message edited by: stephen Kang ]
 
Sham Jowsaki
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Stephen,
I hv followed ur steps, everything seems to be good. I donne understand ur last step
#cd ~i_user/$JAVA_HOME/bin <-- assume u have JAVA_HOME variable on your .bashrc,
otherwise you can go to that directory .e.g) /usr/java/j2sdk_1.4.1_02

yes. I hv installed j2se in /usr/j2se.
Pls explain me the above points..
Thanks
Jowsaki
 
stephen Kang
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sham,
sorry about mistyping.

i_user$cd $JAVA_HOME
i_user$$JAVA_HOME/bin/java --version
like that.
I mean in order to run your j2sdk in your bash,
every time you can open your shell, and do the commands,
e.g)
ex_user$/usr/j2se/bin/java -version or
ex_user$/usr/j2se/bin/javac example.java
But, you can export JAVA_HOME environment variable in your bash shell.
ex_user$export JAVA_HOME=/usr/j2se
ex_user$echo $JAVA_HOME
=> /usr/j2se
ex_user$export PATH=$JAVA_HOME/bin AND
ex_user$javac example.java
or
ex_user$$JAVA_HOME/bin/javac example.java
(means you haven't exported your PATH variable)
=> you can compile at this current shell, but later, you need to export the path when you login again or open the new shell.
misc thing, when you want to unset exported env variable you made on your current shell, simply type
ex_user$unset
it will unset the current(JAVA_HOME) env variable.
you could put those in your .bashrc on your home directory.
export JAVA_HOME=/usr/j2se
export PATH=$JAVA_HOME/bin:/sbin/:/usr/bin:/usr/local/bin ... etc
in order to install netbeans,eclipse,j2ee,and lots of apache stuffs, you better specify your env variable in your .bashrc or /etc/profile to the global though you can export the env variable everytime when you open up the new shell.
or am I missing your point again?
Firstly, you might be confused with bash stuff in linux, but later, you would really enjoy how easy and flexible to use env variable or some other shell command in linux shell to deploy/develope java. I was tired of setting env variable in windows.
Another misc stuff, change the /etc/man.config
add one more line there
MANPATH=/usr/j2se <= in your case
now, you will see the man page of java in your shell
ex_user$man jdb
will show man page for jdb
if you want to update 'whatis' database for man page, simply type
ex_user$makewhatis
[ March 13, 2003: Message edited by: stephen Kang ]
[ March 13, 2003: Message edited by: stephen Kang ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!