Java is not able to handle graphics solutions under Linux

Source: Internet
Author: User

Java calls the local graphics processing library when graphics are processed. When using Java for graphical processing (such as image scaling, image signing, generating reports), there is no problem when running on Windows. If the program is ported to Linux/unix, it is possible that graphics cannot display errors.

Hint message: "Can ' t connect to X11 Window Server" This is because Linux graphics processing requires an X server server.

Workaround:

1. If you have a graphical interface installed on your server, you can resolve it by setting the environment variable: dispaly=127.0.0.1:0.0.

2. If you do not have a graphical interface installed, you can add parameters to the Java Runtime:-djava.awt.headless=true.

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

The changes to Tomcat are as follows:

After you open the%tomcat_home%/bin/catalina.sh file in-djava.io.tmpdir= "$CATALINA _tmpdir", the script that launches Tomcat is added:-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 "[email protected]" start

>> "$CATALINA _base"/logs/catalina.out 2>&1 &

if [!-Z "$CATALINA _pid"]; Then

Echo $! > $CATALINA _pid fi

Fielif ["$" = "Stop"]; Then

Once saved, the graphics can be processed by restarting

Java is not able to handle graphics solutions under Linux

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.