Wednesday, January 25, 2017

XStream - Environment Setup

Try it Option Online

We already have set up Java Programming environment online, so that you can compile and execute all the available examples at the same time when you are doing your theory work. This gives you confidence in what you are reading and to check the result with different options. 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 sample code on our website:
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 in our website code section at the top right corner that will take you to the online compiler. So just make use of it and enjoy your learning.

Local Environment Setup

If you want to set up your environment for Java programming language, then this section explains how to download and set up Java on your machine. Please follow the steps given below to set up you Java environment.
Java SE can be downloaded for free from the link: Download Java.
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 correct installation directories:

Setting Up the Path for Windows 2000/XP

Assuming you have installed Java in c:\Program Files\java\jdk directory:
  • Right-click on 'My Computer' and select 'Properties'.
  • Click the 'Environment variables' button under the 'Advanced' tab.
  • 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 for 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

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 at the end of your '.bashrc: export PATH=/path/to/java:$PATH'

Popular Java Editors

To write Java programs, you will need a text editor. There are even more 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 free and can be downloaded from http://www.netbeans.org/index.html.
  • Eclipse: It is also a Java IDE developed by the eclipse open-source community and can be downloaded from http://www.eclipse.org/.

Download XStream Archive

Download the latest version of XStream jar file from xstream-1.4.7.jar. At the time of writing this tutorial, we have downloaded xstream-1.4.7.jar and copied it into C:\>XStream folder.
OS Archive name
Windows xstream-1.4.7.jar
Linux xstream-1.4.7.jar
Mac xstream-1.4.7.jar

Set XStream Environment

Set the XStream_HOME environment variable to point to the base directory location where xstream jar is stored on your machine. The following table shows how to set the XStream environment on Windows, Linux, and Mac, assuming we've extracted xstream-1.4.7.jar in the XStream folder.
OS Description
Windows Set the environment variable XStream_HOME to C:\XStream
Linux export XStream_HOME=/usr/local/XStream
Mac export XStream_HOME=/Library/XStream

Set CLASSPATH Variable

Set the CLASSPATH environment variable to point to the XStream jar location. The following table shows how to set the CLASSPATH variable on Windows, Linux, and Mac system, assuming we've stored xstream-1.4.7.jar in the XStream folder.
OS Description
Windows Set the environment variable CLASSPATH to %CLASSPATH%;%XStream_HOME%\xstream-1.4.7.jar;
Linux export CLASSPATH=$CLASSPATH:$XStream_HOME/xstream-1.4.7.jar:
Mac export CLASSPATH=$CLASSPATH:$XStream_HOME/xstream-1.4.7.jar:

No comments:

Post a Comment