”;
This chapter takes you through the process of setting up Org.Json on Windows and Linux based systems. Org.Json 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 |
Let us now proceed with the steps to install Org.Json.
Step 1: Verify your Java Installation
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.
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(TM) SE Runtime Environment 18.9 (build 11.0.11+9-LTS-194)
Java HotSpot(TM) 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.
Step 2: Set your Java Environment
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:ProgramFilesjavajdk11.0.11 |
2 |
Linux
Export JAVA_HOME = /usr/local/java-current |
Append the full path of Java compiler location to the System Path.
Sr.No. | Platform & Description |
---|---|
1 |
Windows
Append the String “C:Program FilesJavajdk11.0.11bin” to the end of the system variable PATH. |
2 |
Linux
Export PATH = $PATH:$JAVA_HOME/bin/ |
Execute the command java -version from the command prompt as explained above.
Step 3: Install Org.Json Library
Download the latest version of org.json jar file from org.json @ MVNRepository. At the time of writing this tutorial, we have downloaded json-20211205, and copied it into C:>JSON folder.
OS | Archive name |
---|---|
Windows | json-20180813.jar |
Linux | json-20180813.jar |
Mac | json-20180813.jar |
Step 4: Set JSON_JAVA Environment
Set the JSON_JAVA environment variable to point to the base directory location where org.json jar is stored on your machine. Let”s assuming we”ve stored json-20211205.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
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-20211205.jar;.; |
2 |
Linux
export CLASSPATH = $CLASSPATH:$JSON_JAVA/json-20211205.jar:. |
3 |
Mac
export CLASSPATH = $CLASSPATH:$JSON_JAVA/json-20211205.jar:. |
”;