Java Lab
The PATH variable gives the location of executable files. It is possible to run a program without specifying the PATH but you will need to give full path of executable like %SystemRoot%\TEMP instead of using TEMP or TMP variable.

How to set Environment Variables in Java: Path and Classpath

In Windows

The CLASSPATH variable gives location of the Library Files.

Let’s look into the steps to set the PATH and CLASSPATH

  1. Right Click on the My Computer and select the Properties.

  2. Click on Advanced system settings.

  3. Click on Environment Variables

  4. Click on New... Button of User variables.

  5. Type PATH in the Variable name field.

  6. Copy the path location of bin folder where JDK is installed.

  7. Paste path location of bin folder in Variable value and click on OK Button.

In Linux

Let’s see how to set path in Linux OS:

$ export PATH=$PATH:/home/jdk1.6.01/bin/

In Ubuntu Linux

Edit the system Path file /etc/profile

$ sudo gedit /etc/profile

Add following lines in end.

JAVA_HOME=/usr/lib/jvm/jdk1.x.x -- Where your JDK is installed
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
$ source /etc/profile

Verify the output.

  • Open a terminal and run the following command:
$ javac -version

Continue

Proceed to Lab 1 - First Program.