java调用awt做图片验证码显示的问题解决
错误症状:
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
本文固定链接: https://www.2hei.net/2008/08/25/java_awt_display/ | 2hei.net
最活跃的读者