Get the App
SLTechnology News&Howtos  ›  Servers  › 

Jfreechart cannot be displayed under Unix

Shulou Source: shulou.com Published: 2022-06-03 07:49:26 12月06日 Update

The JFreechart part runs well under the local windows+tomcat, but after the unix+tomcat is put on the server, the chart and picture cannot be displayed normally, the picture shows a red fork, and the text on the picture cannot be displayed.

After searching for many related questions on the Internet, we finally found the root cause of the problem:

When java implements the drawing function on the * unix platform, it relies on the operating system XServer for drawing. Cannot be called when started from the terminal interface.

The detailed explanation and solution are as follows:

Http://qjmouse.javaeye.com/blog/296092

The system uses jfreechart to draw pictures, and there are problems in some * unix systems. The solutions are as follows. Other similar problems can also be solved by reference.

1. The graph cannot be displayed. The exception is: Can't connect to X11 window server using': 0.0' as

The value of the DISPLAY variable.

Reason: when java implements the drawing function on the * unix platform, it relies on the operating system XServer for drawing. Cannot be called when started from the terminal interface.

Solution: use java's headles mode without invoking operating system local resources.

Configuration: go to was console > Server > Application Server > servername > process definition >

Java virtual machine, setting the generic JVM argument to

"- Djava.awt.headless=true", restart WAS.

two。 You can draw, but it appears as a square in Chinese.

Reason: jdk uses the English font.properties description file by default

Solution: replace the font description file with the Chinese version and enter the lib directory where WAS uses JRE, such as / opt/IBM/WebSphere/AppServer/java/jre

/ lib, back up the original font.properties, rename font.properties.zh to font.properties, and restart WAS.

Tags: System drawing problem operating system picture server service function reason platform file interface terminal part Chinese good Chinese version fork graph chart Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Apple vpn Shulou Technology Shulou Information