bash 线程“main”中的异常 java.awt.AWTError: 无法使用“:0.0”作为 DISPLAY 变量的值连接到 X11 窗口服务器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44084381/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Exception in thread "main" java.awt.AWTError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable
提问by Hamid Reza
I have trouble running a Java application in my CentOS server. When I fire the command below:
我在 CentOS 服务器上运行 Java 应用程序时遇到问题。当我触发以下命令时:
java -jar the-application.jar
I receive the following error:
我收到以下错误:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:207)
at java.awt.Window.<init>(Window.java:535)
at java.awt.Frame.<init>(Frame.java:420)
at java.awt.Frame.<init>(Frame.java:385)
at javax.swing.JFrame.<init>(JFrame.java:174)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:312)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:745)
at java.awt.EventQueue.access0(EventQueue.java:103)
at java.awt.EventQueue.run(EventQueue.java:706)
at java.awt.EventQueue.run(EventQueue.java:704)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:715)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:218)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:133)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:122)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:118)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:110)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
I tried to define DISPLAY variable using command below, but this time only the error changed and the command failed again:
我尝试使用下面的命令定义 DISPLAY 变量,但这次只更改了错误并且命令再次失败:
Command to set DISPLAY variable:
设置 DISPLAY 变量的命令:
export DISPLAY=:0.0
The error:
错误:
Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
Based on the recommendations from different forums, I also tried the followeing varibales separately, but there was no luck:
根据不同论坛的建议,我还分别尝试了以下变量,但没有运气:
export DISPLAY=:0
export DISPLAY=:99
export DISPLAY=:99.0
export DISPLAY=:1
export DISPLAY=:1.0
export DISPLAY=127.0.0.1:0
export DISPLAY=127.0.0.1:0.0
export DISPLAY=127.0.0.1:99
export DISPLAY=127.0.0.1:99.0
export DISPLAY=127.0.0.1:1
export DISPLAY=127.0.0.1:1.0
I tried "xhost + localhost" command, so that maybe it can help, however, I receive the error below:
我尝试了“xhost + localhost”命令,因此它可能会有所帮助,但是,我收到以下错误:
-bash: xhost: command not found
Can anyone help me resolve this issue? Thank you all in advance.
谁能帮我解决这个问题?谢谢大家。
采纳答案by Maryam Saeidi
You should install lightDm on your system as mentioned here:
您应该按照此处所述在您的系统上安装 lightDm:
http://siripong-computer-tips.blogspot.co.uk/2015/02/how-to-add-cinnamon-lightdm-to-centos-7.html
http://siripong-computer-tips.blogspot.co.uk/2015/02/how-to-add-cinnamon-lightdm-to-centos-7.html
If you are running CentOS on VMware you should install related tools on your VMware as well.
如果您在 VMware 上运行 CentOS,您也应该在您的 VMware 上安装相关工具。