Json Simple 简明教程
JSON.simple - Environment Setup
Local Environment Setup
JSON.simple 是一个用于 Java 的库,因此首要要求是在你的机器上安装 JDK。
JSON.simple is a library for Java, so the very first requirement is to have JDK installed in your machine.
Step 1: Verify Java Installation in Your Machine
首先,打开控制台并根据您正在使用的操作系统执行 java 命令。
First of all, open the console and execute a java command based on the operating system you are working on.
OS |
Task |
Command |
Windows |
Open Command Console |
c:> java -version |
Linux |
Open Command Terminal |
$ java -version |
Mac |
Open Terminal |
machine:< joseph$ java -version |
让我们验证所有操作系统的输出 −
Let’s verify the output for all the operating systems −
OS |
Output |
Windows |
java version "1.8.0_101" Java™ SE Runtime Environment (build 1.8.0_101) |
Linux |
java version "1.8.0_101" Java™ SE Runtime Environment (build 1.8.0_101) |
Mac |
java version "1.8.0_101" Java™ SE Runtime Environment (build 1.8.0_101) |
如果你尚未在自己的系统上安装 Java,请从 www.oracle.com 以下链接下载 Java 软件开发工具包 (SDK)。对于本教程,我们假设安装的版本是 Java 1.8.0_101。
If you do not have Java installed on your system, then download the Java Software Development Kit (SDK) from the following link www.oracle.com. We are assuming Java 1.8.0_101 as the installed version for this tutorial.
Step 2: Set JAVA Environment
将 JAVA_HOME 环境变量设置为您计算机中安装 Java 的基本目录位置。例如。
Set the JAVA_HOME environment variable to point to the base directory location where Java is installed on your machine. For example.
OS |
Output |
Windows |
Set the environment variable JAVA_HOME to C:\Program Files\Java\jdk1.8.0_101 |
Linux |
export JAVA_HOME = /usr/local/java-current |
Mac |
export JAVA_HOME = /Library/Java/Home |
在系统路径中追加 Java 编译器位置。
Append Java compiler location to the System Path.
OS |
Output |
Windows |
Append the string C:\Program Files\Java\jdk1.8.0_101\bin at the end of the system variable, Path. |
Linux |
export PATH = $PATH:$JAVA_HOME/bin/ |
Mac |
not required |
如上所述,使用命令 java -version 验证 Java 安装。
Verify Java installation using the command java -version as explained above.
Step 3: Download JSON.simple Archive
从 json-simple @ MVNRepository 下载 JSON.simple jar 文件的最新版本。在本教程编写时,我们已经下载了 json-simple-1.1.1.jar,并将其复制到了 C:\>JSON 文件夹。
Download the latest version of JSON.simple jar file from json-simple @ MVNRepository. At the time of writing this tutorial, we have downloaded json-simple-1.1.1.jar, and copied it into C:\>JSON folder.
OS |
Archive name |
Windows |
json-simple-1.1.1.jar |
Linux |
json-simple-1.1.1.jar |
Mac |
json-simple-1.1.1.jar |
Step 4: Set JSON_JAVA Environment
将 JSON_JAVA 环境变量设置为你机器上存储 JSON.simple jar 的基本目录位置。让我们假设我们已经将 json-simple-1.1.1.jar 存储在 JSON 文件夹中。
Set the JSON_JAVA environment variable to point to the base directory location where JSON.simple jar is stored on your machine. Let’s assuming we’ve stored json-simple-1.1.1.jar in the JSON folder.
Sr.No |
OS & Description |
1 |
Windows Set the environment variable JSON_JAVA to C:\JSON |
2 |
Linux export JSON_JAVA = /usr/local/JSON |
3 |
Mac export JSON_JAVA = /Library/JSON |
Step 5: Set CLASSPATH Variable
将 CLASSPATH 环境变量设置为指向 JSON.simple jar 所在位置。
Set the CLASSPATH environment variable to point to the JSON.simple jar location.
Sr.No |
OS & Description |
1 |
Windows Set the environment variable CLASSPATH to %CLASSPATH%;%JSON_JAVA%\json-simple-1.1.1.jar;.; |
2 |
Linux export CLASSPATH = $CLASSPATH:$JSON_JAVA/json-simple-1.1.1.jar:. |
3 |
Mac export CLASSPATH = $CLASSPATH:$JSON_JAVA/json-simple-1.1.1.jar:. |