简体   繁体   中英

Having trouble launching server with Java. Display error [Cent OS 6]

[root@null folder]# java -classpath bin:deps/poi.jar:deps/mysql.jar:deps/mina.jar:deps/slf4j.jar:deps/slf4j-nop.jar:deps/jython.jar:log4j-1.2.15.jar: server.Server

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.access$200(X11GraphicsEnvironment.java:65) *at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:110) *at java.security.AccessController.doPrivileged(Native Method) at sun.awt.X11GraphicsEnvironment.(X11GraphicsEnvironment.java:74) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:188) at java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:102) at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:81) * at java.awt.Window.initGC(Window.java:467) * at java.awt.Window.init(Window.java:487) at java.awt.Window.(Window.java:536) at java.awt.Frame.(Frame.java:420) at java.awt.Frame.(Frame.java:385) * at javax.swing.JFrame.(JFrame.java:180) at server.util.ControlPanel.(ControlPanel.java:20) at server.Server.(Server.java:83)

I'm using a Terminal for this and not a GUI.

Unfortunately, it appears you don't have a valid instance of X server running. Some libraries for Java require that one be running. From my research installing Xvfb ( X Virtual Frame Buffer ) is the solution to your problem. Once it is installed you will need to go to etc/profile

Then add, inside profile, these lines.

if [ -f /usr/X11R6/bin/Xvfb ]; then
/usr/X11R6/bin/Xvfb :1 -screen 0 1024x768x16
fi

export DISPLAY=localhost:1.0

Hope this helps.

you might need to install Xext devel: http://rpmfind.net/linux/rpm2html/search.php?query=libXext.so.6 I can't remember exactly what is the library name for centos ... but it is something like:

yum install libXext-dev

or a variation of it (devel, xext-dev, xext-devel, libxext ... or something similar). I don't have CentOS here :(

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM