java调用awt做图片验证码显示的问题解决
作者: 2hei 发表于2008年8月25日 21:40 版权声明: 可以转载, 转载时务必以超链形式标明文章原始出处和作者信息及版权声明
http://www.2hei.net/mt/2008/08/java-awt-display.html
错误症状:
500 Servlet Exception
java.lang.InternalError: Can't connect to X11 window server using 'localhost:0.0'
as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(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.image.BufferedImage.createGraphics(BufferedImage.java:1041)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
at java.lang.Thread.run(Thread.java:534)
google了半天,试过了安装xorg-x11-Xvfb包,export DISPLAY=:0等等,无奈,没有解决。
最后终于找到了解决方案:
可以在java的jvm上 加入参数 –Djava.awt.headless=true
500 Servlet Exception
java.lang.InternalError: Can't connect to X11 window server using 'localhost:0.0'
as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(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.image.BufferedImage.createGraphics(BufferedImage.java:1041)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
at java.lang.Thread.run(Thread.java:534)
google了半天,试过了安装xorg-x11-Xvfb包,export DISPLAY=:0等等,无奈,没有解决。
最后终于找到了解决方案:
可以在java的jvm上 加入参数 –Djava.awt.headless=true





发表一个评论