您的位置:首页 > 编程语言 > Java开发

Java environment variables and their functionality

2015-09-07 13:54 387 查看
1. PATH env variable

It is used to search the command directory when we use the console type commands. We only can use the javac and java command anywhere after the jdk\bin and jdk\jre\bin directory have been added in to the PATH env variable.

E.g. "C:\Program Files\Java\jdk1.6.0_21\bin;C:\Program Files\Java\jdk1.6.0_21\jre\bin", the ';' is the separator between env variables.

2. CLASSPATH env variable

It is used to search the known classes, which include the default classes used by JVM and the current classes we created. Thus we add '.' directory including the classes in current directory, and the jdk\lib\dt.jar and jdk\lib\tools.jar including the default classes JVM will use.

E.g. ".;C:\Program Files\Java\jdk1.6.0_21\lib\dt.jar;C:\Program Files\Java\jdk1.6.0_21\lib\tools.jar".

3. JAVA_HOME env variable

It is used to indicate the directory of jdk. Many softwares like Eclipse, NetBeans, Tomcat will use this env variable to execute jdk.

E.g, "C:\Program Files\Java\jdk1.6.0_21".

Concrete Steps:

As all the env variables will involve the directory of jdk, we can set the JAVA_HOME first. Then we can use the %JAVA_HOME% make other env variables setting simple.

1. JAVA_HOME=C:\Program Files\Java\jdk1.6.0_21

2. PATH=%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin

3. CLASSPATH=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar

.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: