Saturday, February 23, 2019

Gson - Environment Setup

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 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.
OSArchive name
Windowsgson-2.3.1.jar
Linuxgson-2.3.1.jar
Macgson-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.
OSOutput
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.
OSOutput
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

Popular Posts