java在AIX系统上不能处理图形的解决办法

 

Java在图形处理时调用了本地的图形处理库。在利用Java作图形处理(比如:图片缩放,图片签名,生成报表)时,如果运行在windows上不会出问题。如果将程序移植到Linux/Unix上的时候有可能出现图形不能显示的错误。提示信息:"Can't connect to X11 window server"这是由于Linux的图形处理需要一个X Server服务器。(关于Linux的图形处理模式参考htt p://www.douzhe.com/docs/fbsd2/5.htm)
        通常情况下,人们配置一个基于xNix的web服务器是不会安装X-Server,运行一个不必要的X-server并不是一种好的网络管理方式。对于一个Java服务器来说经常要处理一些图形元素,例如给图片加上水印文字,如果服务器没有安装X-Server,那就没法实现这个功能了。sun公司在JDK1.4的版本里面加入了一个headless服务器,有了这个你只需在jre启动的时候加入一句-Djava.awt.headless=true就可以得到与安装了X-Server一样的效果。下面说一下对于tomcat和weblogic俺是怎么实现这个小小的功能的,如果是tomcat,执行下面的命令:
    export CATALINA_OPTS="-Djava.awt.headless=true"
    然后启动服务即可,如果是weblogic,修改weblogic启动文件(如startWebLogic.sh或startmydomain.sh),拖到最后一行,找到weblogic.Server,在这个前面面加入-Djava.awt.headless=true即可,注意要用空格隔开。

解决办法:

1.如果服务器上安装有图形界面,可以通过设置环境变量:DISPALY=127.0.0.1:0.0解决。

2.如果没有安装图形界面,可以在Java运行时加上参数:-Djava.awt.headless=true。(已测试过,可行)

3.使用PJA库来代替本地图形处理库。

实例参考:
   
部署环境如下:
        机器型号:IBM P690
        操作系统:AIX 5.2.0.0
        图形显示组件:gfreechart1.0
现象:
        采用域下默认的startWebLogic.sh启动应用程序后,涉及到图形显示的地方都不能正常显示,后台日志报
“Can't connect to X11 window server”的错误。采用解决办法中的第二种,可以很好的解决这个问题。
其他两个解决方案没有试验过。

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
What is PJA Toolkit ? PJA (Pure Java AWT) Toolkit is a JavaTM library for drawing graphics developed by eTeks. It is 100% Pure Java and doesn't use any native graphics resource of the system on which the Java Virtual Machine runs. java.awt.Graphics methods such as drawLine (), fillOval (), drawString (),... are implemented in the default JVM with native graphical functions (except in some cases for Java2D) : That means that drawLine () finally calls a GDI system function on Windows or X11 function on a X11/UNIX machine even if the drawing is done in an off-screen image using the class java.awt.Image. This ensures the best performance for drawing graphics with Java. But in a few cases, this default behavior can cause problems that PJA Toolkit library improves : When no X11 Display is available on a UNIX machine (also called headless environment) or when GDI resources are low on Windows, it is impossible to compute off-screen images with java.awt.Graphics methods under a JDK version < 1.4, even if your program doesn't need to display these images. Typically, this situation happens for servlets returning dynamically generated images like pies, charts or web counters. With PJA Toolkit, you don't need to change your Java programs that you expected to run : setting java.awt system property to com.eteks.awt.PJAToolkit is the only required modification to your program with Java 1.1 (see the FAQ and com.eteks.awt.PJAToolkit class documentation for more information). It is also impossible to compute off-screen images when the Java security manager forbids access to any Toolkit or the AWT library. In that case you can although create an instance of com.eteks.awt.PJAImage class which extends java.awt.Image, and draw into it with graphics methods. Drawing with native function doesn't give always the exact same results for each pixel on all platforms. For example, SansSerif font renders differently on MacOS, Windows and other systems : each letter of this font isn't drawn the same, and is different if font anti-aliasing is set or not on the system. On MacOS, circles aren't rendered as specified in Java documentation : fillArc () and drawArc () don't use the same base ellipse... Finally, PJA Toolkit library is supplied under GNU General Public License with its Java source files, and is a good exemple for studying : How pixels are drawn by graphics functions on a computer (com.eteks.awt.PJAGraphics uses Bresenham algorithms to draw lines and circles). How to use the Java paradigm for managing images specified by the ImageConsumer/ImageProducer/ImageObserver interfaces. How Java Toolkit works and what it needs to work (which abstract classes and interfaces to implement). Sources are supplied to allow developers to improve and optimize the graphic drawing methods. com.eteks.awt package files are Java 1.0 to Java 1.4.2 compliant. PJA Toolkit library core classes weighs 140 Ko at run-time (can be reduced to 73 Ko if compressed).

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值