”;
Local Environment Setup
If you still want to set up a local environment for Java programming language, then this section will guide you on how to download and set up Java on your machine. Please follow the steps given below, to set up the environment.
Java SE is freely available from the link Download Java. So you download a version based on your operating system.
Follow the instructions to download Java and run the .exe to install Java on your machine. Once you have installed Java on your machine, you would need to set the environment variables to point to their correct installation directories.
Setting up the Path in Windows 2000/XP
Assuming you have installed Java in c:Program Filesjavajdk directory −
-
Right-click on ”My Computer” and select ”Properties”.
-
Click on the ”Environment variables” button under the ”Advanced” tab.
-
Next, alter the ”Path” variable so that it also contains the path to the Java executable. For example, if the path is currently set to ”C:WINDOWSSYSTEM32”, then change your path to read ”C:WINDOWSSYSTEM32;c:Program Filesjavajdkbin”.
Setting up the Path in Windows 95 / 98 / ME
Assuming you have installed Java in c:Program Filesjavajdk directory −
-
Edit the ”C:autoexec.bat” file and add the following line at the end: ”SET PATH=%PATH%;C:Program Filesjavajdkbin”
Setting up the Path for Linux, UNIX, Solaris, FreeBSD
The environment variable PATH should be set to point to where the Java binaries have been installed. Refer to your shell documentation if you have trouble doing this.
For example, if you use bash as your shell, then you would add the following line to the end of your ”.bashrc: export PATH=/path/to/java:$PATH”
Popular Java Editors
To write your Java programs, you will need a text editor. There are quite a few sophisticated IDEs available in the market. But for now, you can consider one of the following −
-
Notepad − On Windows, you can use any simple text editor like Notepad (Recommended for this tutorial) or TextPad.
-
Netbeans − It is a Java IDE that is open-source and free which can be downloaded from https://netbeans.org/index.html.
-
Eclipse − It is also a Java IDE developed by the Eclipse open-source community and can be downloaded from https://www.eclipse.org/.
Download Gson Archive
Download the latest version of Gson jar file from gson-2.3.1.jar. At the time of writing this tutorial, we downloaded gson-2.3.1.jar and copied it into C:>gson folder.
OS | Archive name |
---|---|
Windows | gson-2.3.1.jar |
Linux | gson-2.3.1.jar |
Mac | gson-2.3.1.jar |
Set Gson Environment
Set the GSON_HOME environment variable to point to the base directory location where Gson jar is stored on your machine.
OS | Output |
---|---|
Windows | Set the environment variable GSON_HOME to C:gson |
Linux | export GSON_HOME=/usr/local/gson |
Mac | export GSON_HOME=/Library/gson |
Set CLASSPATH variable
Set the CLASSPATH environment variable to point to the Gson jar location.
OS | Output |
---|---|
Windows | Set the environment variable CLASSPATH to %CLASSPATH%;%GSON_HOME%gson-2.3.1.jar;.; |
Linux | export CLASSPATH=$CLASSPATH:$GSON_HOME/gson-2.3.1.jar:. |
Mac | export CLASSPATH=$CLASSPATH:$GSON_HOME/gson-2.3.1.jar:. |
”;