zoukankan      html  css  js  c++  java
  • jfreechart图表在linux上运行不显示


    jfreechart图表在windows上运行正常,但在linux上运行出错如下:
    java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
    at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
    at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:134)

    在网上查到:
    “这个错误是因为图表程序是通过AWT实现的,AWT会调用操作系统本地窗口资源绘图,windows对此支持很好,在linux下如果没有进到X window,AWT就不能绘图”

    解决办法:
    [root@localhost logs]# export DISPLAY=:0
    [root@localhost logs]# source /etc/profile
    [root@localhost logs]# env
    看到
    DISPLAY=:0
    表示设置ok。重起tomcat服务就可以了。

    ---------------------------------------------------------
    看到一些网友的做法,自己未曾验证过:
    jasper安装在windows环境运行正常,但是在linux环境中出现错误:java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
    解决方式:
    在JVM中加入-Djava.awt.headless=true
    对于tomcat ,可以修改catalina.sh,加入CATALINA_OPTS="$CATALINA_OPTS -Djava.awt.headless=true "

    如:
    ......
    elif [ "" = "start" ] ; then

    shift
    touch "$CATALINA_BASE"/logs/catalina.out
    CATALINA_OPTS="$CATALINA_OPTS -Djava.awt.headless=true" ##在catalina.sh文件(240行后添加此行)
    if [ "" = "-security" ] ; then
    echo "Using Security Manager"
    shift
    .....

    =======================
    官方问题解决:http://www.jfree.org/jfreechart/faq.html#FAQ10


    请参考:
    http://www.cnflex.org/bbs/archiver/?tid-1.html
    Linux 用户要安装xorg-x11-deprecated-libs包 (Fedora) 获类似支持包以避免如下错误:
    java.lang.UnsatisfiedLinkError: /opt/j2sdk1.4.2_11/jre/lib/i386/libawt.so: libXp.so.6: cannot open shared object file: No such file or directory

    可用rpm -q xorg-x11-deprecated-libs 命令查看包信息
  • 相关阅读:
    php5.3连接sqlserver2005
    U盘文件名称变成乱码的解决方法
    sql小计汇总 rollup用法实例分析(转)
    关于document.all.item遇到IE8时无法正常取到数据
    jQuery 库中的 $() 是什么?
    JavaScript内置可用类型
    jquery中$.get()提交和$.post()提交有区别吗?
    什么是CDN?哪些是流行的jQuery CDN?使用CDN有什么好处?
    说一说Servlet的生命周期?
    request.getAttribute()和 request.getParameter()有何区别?
  • 原文地址:https://www.cnblogs.com/dkblog/p/1980861.html
Copyright © 2011-2022 走看看