Linux上 Can't connect to X11 window server 错误解决方法

Exception in thread "main" [java](javascript:;).lang.InternalError: Can't connect to X11 window [server](javascript:;) using 'localhost:11.0' as the value of the DISPLAY variable. at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method) at sun.awt.X11GraphicsEnvironment.(X11GraphicsEnvironment.java:134) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:141) at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:62) at java.awt.Font.initializeFont(Font.java:308) at java.awt.Font.(Font.java:344) at org.jfree.chart.axis.AxisConstants.(Unknown Source) at org.jfree.chart.axis.Axis.(Unknown Source) at org.jfree.chart.axis.CategoryAxis.(Unknown Source) at org.jfree.chart.ChartFactory.createLineChart(Unknown Source)

linux上就报以上错误原因是windows内核集成了gui,而linux上没有启动x server

解决办法:

1、启动x server2。在java运行参数上加-Djava.awt.headless=true ,应该是在/usr/java/jdk1.6.0_23/bin文件夹下的javac文件中

2、单个程序的启动脚本中增加java的运行参数,比如tomcat

/bin/catalina.sh在所有的(请注意,是所有)-Dcatalina.home="$CATALINA_HOME" /

下面都加上了-Djava.awt.headless=true

你可能感兴趣的:(Linux上 Can't connect to X11 window server 错误解决方法)