Xerces 简明教程

Apache Xerces - Environment Setup

本教程将带你完成在 Windows 和基于 Linux 的系统中设置 Apache Xerces 的过程。按照几个简单的步骤,在没有复杂设置程序的情况下,可以轻松安装 Apache Xerces 并将其集成到你的当前 Java 环境中。安装过程中需要用户管理。

This chapter takes you through the process of setting up Apache Xerces on Windows and Linux based systems. Apache Xerces can be easily installed and integrated with your current Java environment following a few simple steps without any complex setup procedures. User administration is required while installation.

System Requirements

JDK

Java SE 2 JDK 1.5 or above

Memory

1 GB RAM (recommended)

Disk Space

No minimum requirement

Operating System Version

Windows XP or above, Linux

现在,让我们继续进行安装 Apache Xerces 的步骤。

Let us now proceed with the steps to install Apache Xerces.

Step 1: Verify your Java Installation

首先,你所使用的系统需要安装 Java 软件开发套件 (SDK)。要验证这一点,请根据你所使用的平台执行两个命令中的任何一个。

First of all, you need to have the Java Software Development Kit (SDK) installed on your system. To verify this, execute any of the two commands depending on the platform you are working on.

如果 Java 安装成功,那么它将显示你的 Java 安装的当前版本和规范。一个示例输出在以下表格中给出。

If the Java installation successful, then it will display the current version and specification of your Java installation. A sample output is given in the following table.

Platform

Command

Sample Output

Windows

Open Command Console and type − java -version

Java version "1.7.0_60" Java ™ SE Run Time Environment (build 1.7.0_60-b19) Java Hotspot ™ 64-bit Server VM (build 24.60b09,mixed mode)

Linux

Open command terminal and type − $java -version

Java version "1.7.0_25" Open JDK Runtime Environment (rhel-2.3.10.4.el6_4-x86_64) Open JDK 64-Bit Server VM (build 23.7-b01, mixed mode)

  1. We assume the readers of this tutorial have Java SDK version 1.7.0_60 installed on their system.

  2. In case you do not have Java SDK, download its current version from www.oracle.com/technetwork/java/javase/downloads/index.html and have it installed.

Step 2: Set your Java Environment

设置环境变量 JAVA_HOME 以指向计算机上安装 Java 的基本目录位置。例如,

Set the environment variable JAVA_HOME to point to the base directory location where Java is installed on your machine. For example,

Sr.No.

Platform & Description

1

Windows Set JAVA_HOME to C:\ProgramFiles\java\jdk1.7.0_60

2

Linux Export JAVA_HOME = /usr/local/java-current

将 Java 编译器位置的完整路径附加到系统路径。

Append the full path of the Java compiler location to the System Path.

Sr.No.

Platform & Description

1

Windows Append the String "C:\Program Files\Java\jdk1.7.0_60\bin" to the end of the system variable PATH.

2

Linux Export PATH = $PATH:$JAVA_HOME/bin/

如上所示从命令提示符处执行命令 java version。

Execute the command java version from the command prompt as explained above.

Step 3: Install Apache Xerces Library

https://xerces.apache.org/mirrors.cgi" 下载 Apache Xerces 的最新版本,并将其内容解压到一个文件夹中,以便从该文件夹链接必需的库到你的 Java 程序中。假设这些文件已经收集到 C 驱动器上的一个文件夹 xerces-2_12_1 中。

Download the latest version of Apache Xerces from https://xerces.apache.org/mirrors.cgi" and unzip its contents to a folder from where the required libraries can be linked to your Java program. Let us assume the files are collected in a folder xerces-2_12_1 on the C drive.

将上图中突出显示的五个 jar 的完整路径添加到 CLASSPATH。

Add the complete path of the five jars as highlighted in the above image to the CLASSPATH.

Sr.No.

Platform & Description

1

Windows Append the following strings to the end of the user variable CLASSPATH − C:\xerces-2_12_1\resolver.jar; C:\xerces-2_12_1\serializer.jar; C:\xerces-2_12_1\xercesImpl.jar; C:\xerces-2_12_1\xercesSamples.jar; C:\xerces-2_12_1\xml-apis.jar;

2

Linux Export CLASSPATH = $CLASSPATH − /usr/share/xerces-2_12_1\resolver.jar; /usr/share/xerces-2_12_1\serializer.jar; /usr/share/xerces-2_12_1\xercesImpl.jar; /usr/share/xerces-2_12_1\xercesSamples.jar; /usr/share/xerces-2_12_1\xml-apis.jar;