jsoup - Environment Setup


Advertisements

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 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

Java 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)

Mac

Java 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)

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/technetwork/java/javase/downloads/index.html. We are assuming Java 11.0.11 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\jdk11.0.11
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\jdk11.0.11\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 jsoup Archive

Download the latest version of jsoup jar file from Maven Repository. At the time of writing this tutorial, we have downloaded jsoup-1.14.3.jar and copied it into C:\>jsoup folder.

OS Archive name
Windows jsoup-1.14.3.jar
Linux jsoup-1.14.3.jar
Mac jsoup-1.14.3.jar

Step 4: Set jsoup Environment

Set the JSOUP_HOME environment variable to point to the base directory location where jsoup jar is stored on your machine. Let's assuming we've stored jsoup-1.14.3.jar in the JSOUP folder.

Sr.No OS & Description
1

Windows

Set the environment variable JSOUP_HOME to C:\JSOUP

2

Linux

export JSOUP_HOME = /usr/local/JSOUP

3

Mac

export JSOUP_HOME = /Library/JSOUP

Step 5: Set CLASSPATH Variable

Set the CLASSPATH environment variable to point to the JSOUP jar location.

Sr.No OS & Description
1

Windows

Set the environment variable CLASSPATH to %CLASSPATH%;%JSOUP_HOME%\jsoup-1.14.3.jar;.;

2

Linux

export CLASSPATH = $CLASSPATH:$JSOUP_HOME/jsoup-1.14.3.jar:.

3

Mac

export CLASSPATH = $CLASSPATH:$JSOUP_HOME/jsoup-1.14.3.jar:.

Advertisements