错误详情:
[[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