Can‘t connect to X11 window server using ‘:1.0‘ as

错误详情:

[[email protected] import_jre]# ./run_linux64
/root/lyy/import_jre
/root/lyy/import_jre/lib
/root/lyy/import_jre/jre8_openjdk64/bin
classpath is: /root/lyy/import_jre/lib/myapp.jar:/root/lyy/import_jre/jre8_openjdk64/lib/ext:/root/lyy/import_jre/lib/lib/commons-io-2.0.1.jar:/root/lyy/import_jre/lib/lib/dom4j-1.6.1.jar:/root/lyy/import_jre/lib/lib/hgdb-1.3-jdbc41.jar:/root/lyy/import_jre/lib/lib/log4j-1.2.17.jar:/root/lyy/import_jre/lib/lib/poi4excel.jar:/root/lyy/import_jre/lib/lib/slf4j-api-1.7.2.jar:/root/lyy/import_jre/lib/lib/slf4j-log4j12-1.7.2.jar
run now...
No protocol specified
Exception in thread "main" java.awt.AWTError: Can‘t connect to X11 window server using ‘:1.0‘ as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.access$200(X11GraphicsEnvironment.java:66)
at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:187)
at java.security.AccessController.doPrivileged(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:146)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:260)
at java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:102)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:81)
at sun.awt.X11.XToolkit.<clinit>(XToolkit.java:123)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:260)
at java.awt.Toolkit$2.run(Toolkit.java:860)
at java.awt.Toolkit$2.run(Toolkit.java:855)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:854)
at javax.swing.UIManager.getSystemLookAndFeelClassName(UIManager.java:611)
at hgdbmonitor.view.MonitorView.main(MonitorView.java:2147)

错误原因:找错误时应该去看错误提示Can‘t connect to X11 window server using ‘:1.0‘ as the value of the DISPLAY variable.从中我们找到了两个关键点:x11 windows server和变量DISPLAY。

问题解决:

1.通过查询我们得知,Linux默认情况下是启动x11 windows server的,而且它是与windows的图形工具显示相关;

2.变量DISPLAY的值与程序界面显示在机器的哪个图形化终端有关,通过执行who命令和who am i 命令,可以知道当前图形化终端是第n个(如下是第2个),那么变量DISPLAY的值应该是IP:(n-1)或者:(n-1)(如下是:1.0),只有这样java图形程序的界面才能正常显示出来。

[[email protected] import_jre]# who
root   tty2    2015-02-06 13:18
root   pts/1   2015-02-06 13:42(192.168.100.126)
highgo pts/2   2015-02-06 13:42(:1.0)
[[email protected] import_jre]# who am i
highgo pts/2   2015-02-06 13:42(:1.0)
[[email protected] import_jre]# echo $DISPLAY
:1.0

如果DISPLAY的值不匹配,可以询问该机器的管理员查看机器是否正常开启,或者找其他图形终端的访问者让其关闭远程桌面访问,仅保留你的远程桌面,然后再尝试重新执行程序。

参考资料:http://www.itpub.net/thread-1633000-1-1.html

时间: 2024-10-07 13:21:21

Can‘t connect to X11 window server using ‘:1.0‘ as的相关文章

Can&#39;t connect to X11 window server using &#39;:1.0&#39; as the value of the DISPLAY variable.

安装oracle数据时需要用到图形界面安装,当我们用root用户登录后切换到oracle用户时运行./runInstaller提示报错: Can't connect to X11 window server using ':1.0' as the value of the DISPLAY variable. 这是因为没有赋予oracle运行图形界面的权限,这时只要在root下运行xhost + 然后回车即可解决问题.[[email protected] ~]# xhost +access con

oracle Can&#39;t connect to X11 window server using &#39;:0.0&#39; 解决方法

Can't connect to X11 window server using ':0.0' 解决方法 1. 以oracle 用户登陆X window 或者 2. root 身份执行 # xhost + oracle Can't connect to X11 window server using ':0.0' 解决方法

Linux 下centos7启动 Tomcat 抛出Can&#39;t connect to X11 window server 问题的解决方法

1 问题 今天启动 Tomcat 后,登录页验证码不见了.在 localhost.xxx.log 发现以下错误: org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [StickyCaptcha] in context with path [/web2] threw exception [Servlet execution threw an exception] with root

CentOS8安装pycharm报错【Can&#39;t connect to X11 window server using &#39;:0&#39; as the value of the DISPLAY variable. 】

在CentOS8 安装pycharm报出如下错误,原来是自己画蛇添足的用sudo执行pycharm.sh,没有按照Install说明里边的直接执行 ./pycharm.sh. 原因见这里:https://www.cnblogs.com/qingqing74647464/p/8685837.html OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will l

redis error It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail. SocketFailure on PING

应用redis出现如下错误 It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail. SocketFailure on PING 参考stack overflow上文章 http://stackoverflow.com/questions/30895507/it-was-not-possible-to-connec

解决mysql报错Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’

启动mysql 报错: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 1.先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动.另外看看是不是权限问题. 2.确定你的mysql.sock是不是在那个位置,mysql -u 你的mysql用户名 -p -S /var/lib/mysql/

解决MySQL workbench的Can&#39;t connect to MySQL server on &#39;127.0.0.1&#39;(10061)问题

如题,今天打开MySQL时,出现了这种问题,无法连接到数据库 问题原因:The error (2003) Can't connect to MySQL server on 'server' (10061) indicates that the network connection has been refused. You should check that there is a MySQL server running, that it has network connections enab

mysql连接报错 ERROR 2002 (HY000): Can&#39;t connect to local MySQL server through socket

安装完mysql连接报错: [[email protected] app]# mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) [[email protected] app]# mysql -uroot -p Enter password:  ERROR 2002 (HY000): Can't connect to local M

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var mysql 启动不了

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var mysql 启动不了 ps -A | grep -i mysql kill 列出来的进程 service mysql start 我的问题就解决了 ---------------------------------------------- Fedora8启动mysql 报错:ERROR 2002 (HY000): Can’t connect