JDK Environment Variables

Download Report

Transcript JDK Environment Variables

COP 3530
JDK Environment Variables
COP 3530
JDK Environment Variables
Environment Variables
• Environment variables are a set of dynamic values that can affect the way
processes behave on a computer. [1]
COP 3530
JDK Environment Variables
PATH
• PATH is an environment variable listing a set of paths to directories where
executables may be found. [2]
COP 3530
JDK Environment Variables
CLASSPATH
• CLASSPATH is an environment variable that tells the Java Virtual Machine where to
look for user-defined classes and packages in Java programs. [3]
COP 3530
JDK Environment Variables
Setting the PATH and CLASSPATH in Microsoft Windows Vista
• Step 1: Click Start → Control Panel → System and Maintenance → System.
COP 3530
JDK Environment Variables
Setting the PATH and CLASSPATH in Microsoft Windows Vista
• Step 2: Select Advanced system settings.
COP 3530
JDK Environment Variables
Setting the PATH and CLASSPATH in Microsoft Windows Vista
• Step 3: On the Advanced tab of the System Properties window, select Environment
Variables.
COP 3530
JDK Environment Variables
Setting the PATH
• Step 4a: Update your system PATH by selecting it in the
System variables list and clicking Edit. If the PATH
variable does not exit, create a new one via New.
Append the location of the bin folder of your JDK
installation to PATH in System variables. A typical value for
the location is below.
C:\Program Files\Java\jdk1.6.0_<version>\bin.
The PATH environment variable is a series of directories
separated by semi-colons (;) and is not case sensitive.
Microsoft Windows looks for programs in the PATH
directories in order, from left to right.
You should only have one bin directory for a JDK in the path
at a time.
If you are not sure where to add the path, append it to the
right end of the PATH.
The new path takes effect in each new command window
you open after setting the PATH variable.
COP 3530
JDK Environment Variables
Setting the CLASSPATH
• Step 4b: Update your user CLASSPATH by selecting it in
the User variables list and clicking Edit. If the CLASSPATH
variable does not exit, create a new one via New.
Append the working directory (if it is not listed) and the
directory of the code for the textbook. An example entry is
below.
.; C:\COP3530\eprogs
The symbol “.” signifies the working directory.
The changes take effect in each new command window you
open after setting the CLASSPATH variable.
COP 3530
JDK Environment Variables
Setting the PATH and CLASSPATH in Microsoft Windows
• Step 5: Test your settings.
Open a command prompt and go to the directory of the code for the texbook. Enter the dataStructures
directory, then run the commands below at the prompt.
javac ArrayLinearList.java
java dataStructures.ArrayLinearList
The desired output is below.
Initial size is 0
The list is empty
List size is 4
The list is [1, 2, 4, 6]
The index of 4 is 2
3 not found
Element at 0 is 1
Element at 3 is 6
2 removed
The list is [1, 4, 6]
6 removed
The list is [1, 4]
The list is not empty
List size is 2
COP 3530
JDK Environment Variables
References
• [1] http://en.wikipedia.org/wiki/Environment_variable
• [2] http://en.wikipedia.org/wiki/Path_(computing)
• [3] http://en.wikipedia.org/wiki/Classpath_(Java)