Commons Io 简明教程
Apache Commons IO - Environment Setup
在本章中,我们将了解 Apache Commons IO 的本地环境设置以及如何设置 Windows 2000/XP、Windows 95/98/ME 等的 Commons IO 路径。我们还将了解一些流行的 Java 编辑器以及如何下载 Commons IO 存档。
In this chapter, we will learn about the local environment setup of Apache Commons IO and how to set up the path of Commons IO for Windows 2000/XP, Windows 95/98/ME etc. We will also understand about some popular java editors and how to download Commons IO archive.
Verify your Java Installation
首先,你的系统中需要安装 Java 软件开发工具包 (SDK)。要验证这一点,请根据所使用的平台执行以下两个命令。
First of all, you need to have 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 has been done properly, 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 "11.0.11" 2021-04-20 LTS Java™ SE Runtime Environment 18.9 (build 11.0.11+9-LTS-194) Java HotSpot™ 64-Bit Server VM 18.9 (build 11.0.11+9-LTS-194, mixed mode) |
Linux |
Open command terminal and type − $java -version |
java version "11.0.11" 2021-04-20 LTS Open JDK Runtime Environment 18.9 (build 11.0.11+9-LTS-194) Open JDK 64-Bit Server VM (build 11.0.11+9-LTS-194, mixed mode) |
-
We assume the readers of this tutorial have Java SDK version 11.0.11 installed on their system.
-
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.
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\jdk11.0.11 |
2 |
Linux Export JAVA_HOME = /usr/local/java-current |
将 Java 编译器位置的完整路径附加到系统路径。
Append the full path of Java compiler location to the System Path.
Sr.No. |
Platform & Description |
1 |
Windows Append the String "C:\Program Files\Java\jdk11.0.11\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.
Popular Java Editors
要编写 Java 程序,您需要一个文本编辑器。市场上有许多复杂的集成开发环境 (IDE)。但是现在,您可以考虑以下项之一:
To write your Java programs, you need a text editor. There are many sophisticated integrated development environment (IDEs) available in the market. But for now, you can consider one of the following −
-
Notepad − On Windows machine you can use any simple text editor like Notepad (Recommended for this tutorial), TextPad.
-
Netbeans − It is a Java IDE that is open-source and free which can be downloaded from www.netbeans.org/index.html.
-
Eclipse − It is also a Java IDE developed by the eclipse open-source community and can be downloaded from www.eclipse.org.
Download Common IO Archive
从 commons-io-2.11.0-bin.zip 下载 Apache Common IO jar 文件的最新版本。在编写本教程时,我们已经下载了 commons-io-2.11.0-bin.zip 并将其复制到 C:\>Apache 文件夹中。
Download the latest version of Apache Common IO jar file from commons-io-2.11.0-bin.zip. At the time of writing this tutorial, we have downloaded commons-io-2.11.0-bin.zip and copied it into C:\>Apache folder.
OS |
Archive name |
Windows |
commons-io-2.11.0-bin.zip |
Linux |
commons-io-2.11.0-bin.tar.gz |
Mac |
commons-io-2.11.0-bin.tar.gz |
Set Apache Common IO Environment
设置 APACHE_HOME 环境变量以指向机器上存储 Apache jar 的基本目录位置。假设我们在各种操作系统中将 commons-io-2.11.0-bin.zip 提取到 Apache 文件夹中,如下所示。
Set the APACHE_HOME environment variable to point to the base directory location where Apache jar is stored on your machine. Assuming, we’ve extracted commons-io-2.11.0-bin.zip in Apache folder on various Operating Systems as follows.
OS |
Output |
Windows |
Set the environment variable APACHE_HOME to C:\Apache |
Linux |
export APACHE_HOME=/usr/local/Apache |
Mac |
export APACHE_HOME=/Library/Apache |
Set CLASSPATH Variable
设置 CLASSPATH 环境变量以指向 Common IO jar 位置。假设您已将 commons-io-2.11.0-bin.zip 存储在各种操作系统的 Apache 文件夹中,如下所示。
Set the CLASSPATH environment variable to point to the Common IO jar location. Assuming, you have stored commons-io-2.11.0-bin.zip in Apache folder on various Operating Systems as follows.
OS |
Output |
Windows |
Set the environment variable CLASSPATH to %CLASSPATH%;%APACHE_HOME%\commons-io-2.11.0.jar;. |
Linux |
export CLASSPATH=$CLASSPATH:$APACHE_HOME/commons-io-2.11.0.jar:. |
Mac |
export CLASSPATH=$CLASSPATH:$APACHE_HOME/commons-io-2.11.0.jar:. |