Solution for Java not processing graphics in Linux

Source: Internet
Author: User
Tags image processing library
How to solve the problem that Java cannot process graphics in Linux-Linux general technology-Linux programming and kernel information. For details, refer to the following section. Java calls a local image processing library during graph processing. When using Java for graphic processing (for example, image scaling, image signature, and report generation), there is no problem if the program runs on windows. If the program is transplanted to Linux/Unix, the image cannot be displayed.

Tip: "Can't connect to X11 window server". This is because an X Server is required for graph processing in Linux.

Solution:
1. If a graphical interface is installed on the server, you can set the environment variable DISPALY = 127.0.0.1: 0.0.

2. If the graphic interface is not installed, you can add the parameter-Djava. awt. headless = true during Java runtime.

3. Use the PJA library instead of the local image processing library.

Modify Tomcat as follows:
Open the % atat_home %/bin/catalina. sh file in section 86% of the file and add the following to the Tomcat Startup Script:-Djava. awt. headless = true \

Refer:
"$ _ 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 the image is saved, restart the system to process the image.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.