Java. awt processing in Linux

Source: Internet
Author: User
In Linux, java. awt processing-general Linux technology-Linux programming and kernel information. The following is a detailed description. Environment: Linux + Websphere5.1 + db2

The image watermark function runs normally on the Windows platform. On the Linux platform, the program reports an error and the awt class cannot be found.
I added the./bin/startServer. sh file to the websphere Startup File.

-Djava. awt. headless = true (Note: jdk1.4 or a later version can be added)

"$ JAVA_HOME"/bin/java \
$ DEBUG \
-Dws. ext. dirs = "$ WAS_EXT_DIRS "\
-Classpath "$ WAS_CLASSPATH "\
-Dwas. install. root = "$ WAS_HOME "\
-Djava. awt. headless = true \
$ USER_INSTALL_PROP \
Com. ibm. ws. bootstrap. WSLauncher \
$ SHELL "$ CONFIG_ROOT" "$ WAS_CELL" "$ WAS_NODE" "$ @"


After the above Code is added, the java. awt class can run, but a new error is reported. The error log is as follows:

SRVE0026E: [Servlet Error]-[Can't connect to X11 window server using ': 0.0' as the value of the DISPLAY variable.]: java. lang. internalError: Can't connect to X11 window server using ': 100'
As the value of the DISPLAY variable.
At sun. awt. X11GraphicsEnvironment. initDisplay (Native Method)
At sun. awt. X11GraphicsEnvironment. (X11GraphicsEnvironment. java: 161). null (Unknown Source)
At java. lang. Class. forName1 (Native Method)
At java. lang. Class. forName (Class. java (Compiled Code ))
At java. awt. GraphicsEnvironment. getLocalGraphicsEnvironment (GraphicsEnvironment. java: 90)
At sun. awt. motif. MToolkit. (MToolkit. java: 109). null (Unknown Source)
At java. lang. Class. forName1 (Native Method)
At java. lang. Class. forName (Class. java (Compiled Code ))
At java. awt. Toolkit $ 2.run( Toolkit. java: 754)
At java. security. AccessController. doPrivileged (Native Method)
At java. awt. Toolkit. getdefatooltoolkit (Toolkit. java: 745)

The main cause of the above problems is the DISPLAY settings. Also Add the following code to the webspere/bin/startServer. sh file:

PLATFORM = '/bin/uname'
Case $ PLATFORM in
AIX)
EXTSHM = ON
LIBPATH = "$ WAS_LIBPATH": $ LIBPATH
Export libpath extshm ;;
Linux)
LD_LIBRARY_PATH = "$ WAS_LIBPATH": $ LD_LIBRARY_PATH
Export DISPLAY = 127.0.0.1: 0
Export LD_LIBRARY_PATH ;;
SunOS)
LD_LIBRARY_PATH = "$ WAS_LIBPATH": $ LD_LIBRARY_PATH
Export LD_LIBRARY_PATH ;;
HP-UX)
SHLIB_PATH = "$ WAS_LIBPATH": $ SHLIB_PATH
Export SHLIB_PATH ;;
Esac


Then restart the websphere service, and then the image watermark can run normally.
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.