Java calls the local graphics processing library during graphics processing. When using Java for graphics processing (such as image scaling, image signature, and report generation), there will be no problem if it is run on Windows. If you transplant the program to Linux/Unix, there may be an error that the graphics cannot be displayed.
Prompt message: "Can't connect to X11 window server" This is because Linux graphics processing requires an X Server.
Solution:
1. If a graphical interface is installed on the server, it can be solved by setting the environment variable: DISPALY=127.0.0.1:0.0.
2. If the graphical interface is not installed, you can add parameters when running Java: -Djava.awt.headless=true.
3. Use the PJA library instead of the local graphics processing library.
The modifications to Tomcat are as follows:
Open the %Tomcat_home%/bin/catalina.sh file and add -Djava.io.tmpdir="$CATALINA_TMPDIR" to the script that starts Tomcat: -Djava.awt.headless=true
"$_RUNJAVA" $JAVA_OPTS $CATALINA_OPTS
-Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS"
-classpath "$CLASSPATH"
-Dcatalina.base="$CATALINA_BASE"
-Dcatalina.home="$CATALINA_HOME"
-Djava.io.tmpdir="$CATALINA_TMPDIR"
-Djava.awt.headless=true
org.apache.catalina.startup.Bootstrap "$@" start
>> "$CATALINA_BASE"/logs/catalina.out 2>&1 &
if [ ! -z "$CATALINA_PID" ]; then
echo $! > $CATALINA_PID fi
fielif [ "$1" = "stop" ] ; then
After saving, restart and you can work on the graphics.