org.json - Environment Setup


Advertisements

Local Environment Setup

JSON.simple is a library for Java, so the very first requirement is to have JDK installed in your machine.

System Requirement

JDK 1.5 or above.
Memory No minimum requirement.
Disk Space No minimum requirement.
Operating System No minimum requirement.

Step 1: Verify Java Installation in Your Machine

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(TM) SE Runtime Environment (build 1.8.0_101)

Linux

java version "1.8.0_101"

Java(TM) SE Runtime Environment (build 1.8.0_101)

Mac

java version "1.8.0_101"

Java(TM) SE Runtime Environment (build 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

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

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

Verify Java installation using the command java -version as explained above.

Step 3: Download org.json Archive

Download the latest version of org.json jar file from org.json @ MVNRepository. At the time of writing this tutorial, we have downloaded json-20180813, 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-20180813.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-20180813.jar;.;

2

Linux

export CLASSPATH = $CLASSPATH:$JSON_JAVA/json-20180813.jar:.

3

Mac

export CLASSPATH = $CLASSPATH:$JSON_JAVA/json-20180813.jar:.

Advertisements