Xstream 简明教程
Xstream - Environment
在本章,我们将讨论为 Java 设置宜人环境的事物的不同方面。
In this chapter, we will discuss on the different aspects of setting up a congenial environment for Java.
Local Environment Setup
如果您想为 Java 编程语言设置您的环境,那么本部分将说明如何在计算机上下载和设置 Java。请按照下列步骤设置您的 Java 环境。
If you want to set up your environment for Java programming language, then this section explains how to download and set up Java on your machine. Please follow the steps given below to set up you Java environment.
Java SE 可以从此链接免费下载:
Java SE can be downloaded for free from the link −
按照说明下载 Java 并运行 .exe 以在计算机上安装 Java。在您的计算机上安装 Java 后,您需要设置环境变量来指向正确的安装目录:
Follow the instructions to download Java and run the .exe to install Java on your machine. Once you have installed Java on your machine, you would need to set the environment variables to point to correct installation directories −
Setting Up the Path for Windows 2000/XP
假设你已将 Java 安装在 c:\Program Files\java\jdk 目录中 −
Assuming you have installed Java in c:\Program Files\java\jdk directory −
-
Right-click on 'My Computer' and select 'Properties'.
-
Click the 'Environment variables' button under the 'Advanced' tab.
-
Alter the 'Path' variable so that it also contains the path to the Java executable. For example, if the path is currently set to 'C:\WINDOWS\SYSTEM32', then change your path to read 'C:\WINDOWS\SYSTEM32;c:\Program Files\java\jdk\bin'.
Setting Up the Path for Windows 95/98/ME
假设你已将 Java 安装在 c:\Program Files\java\jdk 目录中 −
Assuming you have installed Java in c:\Program Files\java\jdk directory −
-
Edit the 'C:\autoexec.bat' file and add the following line at the end − 'SET PATH = %PATH%;C:\Program Files\java\jdk\bin'
Setting Up the Path for Linux, UNIX, Solaris, FreeBSD
环境变量 PATH 应设置为指向已安装 Java 二进制文件的位置。如果你在这方面遇到问题,请参阅 shell 文档。
Environment variable PATH should be set to point to where the Java binaries have been installed. Refer to your shell documentation if you have trouble doing this.
例如,如果你使用 bash 作为 shell,则需要在“‘.bashrc: export PATH=/path/to/java:$PATH’”的末尾添加以下行
For example, if you use bash as your shell, then you would add the following line at the end of your '.bashrc: export PATH=/path/to/java:$PATH'
Popular Java Editors
要编写 Java 程序,您需要一个文本编辑器。市场上有更加复杂的 IDE。但是现在,您可以考虑以下一项:
To write Java programs, you will need a text editor. There are even more sophisticated IDEs available in the market. But for now, you can consider one of the following −
-
Notepad − On Windows, you can use any simple text editor like Notepad (Recommended for this tutorial) or TextPad.
-
Netbeans − It is a Java IDE that is free and can be downloaded from https://www.netbeans.org/index.html.
-
Eclipse − It is also a Java IDE developed by the eclipse open-source community and can be downloaded from https://www.eclipse.org/.
Download XStream Archive
从 XStream download page 下载 XStream jar 文件的最新版本。在本教程的编写时,我们已经下载了 xstream-1.4.18.jar 并将其复制到 C:\>XStream 文件夹。
Download the latest version of XStream jar file from XStream download page. At the time of writing this tutorial, we have downloaded xstream-1.4.18.jar and copied it into C:\>XStream folder.
OS |
Archive name |
Windows |
xstream-1.4.18.jar |
Linux |
xstream-1.4.18.jar |
Mac |
xstream-1.4.18.jar |
Set XStream Environment
设置 XStream_HOME 环境变量,以指向存储在计算机上的 xstream jar 的基本目录位置。以下表格显示了如何在 Windows、Linux 和 Mac 上设置 XStream 环境,假设我们在 XStream 文件夹中解压了 xstream-1.4.18.jar。
Set the XStream_HOME environment variable to point to the base directory location where xstream jar is stored on your machine. The following table shows how to set the XStream environment on Windows, Linux, and Mac, assuming we’ve extracted xstream-1.4.18.jar in the XStream folder.
Sr.No. |
OS & Description |
1 |
Windows Set the environment variable XStream_HOME to C:\XStream |
2 |
Linux export XStream_HOME=/usr/local/XStream |
3 |
Mac export XStream_HOME=/Library/XStream |
Set CLASSPATH Variable
设置 CLASSPATH 环境变量来指向 XStream jar 位置。以下表格演示了如何在 Windows、Linux 和 Mac 系统上设置 CLASSPATH 变量,假设我们已将 xstream-1.4.18.jar 存储在 XStream 文件夹中。
Set the CLASSPATH environment variable to point to the XStream jar location. The following table shows how to set the CLASSPATH variable on Windows, Linux, and Mac system, assuming we’ve stored xstream-1.4.18.jar in the XStream folder.
Sr.No. |
OS & Description |
1 |
Windows Set the environment variable CLASSPATH to %CLASSPATH%;%XStream_HOME%\xstream-1.4.18.jar; |
2 |
Linux export CLASSPATH=$CLASSPATH:$XStream_HOME/xstream-1.4.18.jar; |
3 |
Mac export CLASSPATH=$CLASSPATH:$XStream_HOME/xstream-1.4.18.jar; |