Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java Graphics2D problem  RSS feed

 
jenny wang
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I create an Image using JAVA Graphics2D API.
The code is running well in Windows. But I got the following error in UNIX server. It seems that it has trouble with X11 window. Anybody knows how to solve this problem?
Thanks in advance!
jenny
Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
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:59)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:120)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:58)
at java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1011)
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm moving this to the "Other Java APIs" forum. http://www.javaranch.com/ubb/Forum45/HTML/000243.html
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is that you need an X server hooked up to the Unix box. Then you need to set the DISPLAY variable. You should be doing something like:
set DISPLAY=hostname:0.0
where hostname is the name of the machine on which the X server is running. If it is the same machine as you are running on then it will be the uname of your machine.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!