Contact at or 8097636691
Responsive Ads Here

Friday, 6 July 2018

Gson - Environment Setup

Gson - Environment Setup

Try it Option Online

You do not have to set up your own environment to start learning Gson. We have already set up an online Java Programming environment for you. This platform allows you to compile and execute all the available examples online and analyze the output with different options. We believe it will boost your confidence and make your learning an enjoyable activity. Feel free to modify any example and execute it online.
Try the following example using the Try it option available at the top right corner of the following sample code box −
public class MyFirstJavaProgram {  
   public static void main(String []args) { 
      System.out.println("Hello World"); 
For most of the examples given in this tutorial, you will find a Try it option. Please do use this option and enjoy your learning.

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 Files\java\jdk 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:\WINDOWS\SYSTEM32', then change your path to read 'C:\WINDOWS\SYSTEM32;c:\Program Files\java\jdk\bin'.

Setting up the Path in Windows 95 / 98 / ME

Assuming you have installed Java in c:\Program Files\java\jdk directory −
  • Edit the 'C:\autoexec.bat' file and add the following line at the end: 'SET PATH=%PATH%;C:\Program Files\java\jdk\bin'

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
  • Eclipse − It is also a Java IDE developed by the Eclipse open-source community and can be downloaded from

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.
OSArchive name

Set Gson Environment

Set the GSON_HOME environment variable to point to the base directory location where Gson jar is stored on your machine.
WindowsSet the environment variable GSON_HOME to C:\gson
Linuxexport GSON_HOME=/usr/local/gson
Macexport GSON_HOME=/Library/gson

Set CLASSPATH variable

Set the CLASSPATH environment variable to point to the Gson jar location.
WindowsSet the environment variable CLASSPATH to %CLASSPATH%;%GSON_HOME%\gson-2.3.1.jar;.;
Linuxexport CLASSPATH=$CLASSPATH:$GSON_HOME/gson-2.3.1.jar:.
Macexport CLASSPATH=$CLASSPATH:$GSON_HOME/gson-2.3.1.jar:.

No comments:

Post a Comment