23 August 2010
0 How to set Environment variables for Java
How to set Environment variables for Java?
• Environmental variable is a variable that describes the operating environment of the process
• Common environment variables describe the home directory, command search path etc.
Environment variables used by JVM
JAVA_HOME
This environment variable is pointing to the Java Installation directory. This environment variable is used to derive all other environment variables used by JVM
In Windows:
set JAVA_HOME=C:\ProgramFiles\JAVA\jdk1.4.3
In UNIX:
export JAVA_HOME=/var/usr/java
set JAVA_HOME=C:\ProgramFiles\JAVA\jdk1.4.3
In UNIX:
export JAVA_HOME=/var/usr/java
CLASSPATH
Path variable is used by OS to locate executable files
In Windows:
set PATH=%PATH%;%JAVA_HOME%\lib\tools.jar
In UNIX:
set PATH=$PATH:$JAVA_HOME/lib/tools.jar:.
set PATH=%PATH%;%JAVA_HOME%\lib\tools.jar
In UNIX:
set PATH=$PATH:$JAVA_HOME/lib/tools.jar:.
Do the Environmental variable settings by typing the given commands in the Command Prompt and Type ‘javac’. It will display all the options of using javac as shown in the diagram. If it says bad command or file name then check the path setting.
Alternate way to set CLASSPATH
In Windows:
set PATH=%PATH%;%JAVA_HOME%\bin
In UNIX:
set PATH=$PATH:$JAVA_HOME/bin
• This approach helps in managing multiple versions of Java – Changing JAVA_HOME will reflect on CLASSPATH and PATH as well.
set PATH=%PATH%;%JAVA_HOME%\bin
In UNIX:
set PATH=$PATH:$JAVA_HOME/bin
Labels:
Basic Java,
How to,
Java Installation,
Java Tutorial,
Technologies,
Tutorials
Subscribe to:
Post Comments (Atom)
0 comments:
Please give your valuable comments.