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
.
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
.
相关文章推荐
- Java虚拟机(JVM)中的内存设置详解
- Java代理模式
- Struts2 同时支持/* 和.do *.action 的匹配
- Hibernate所有缓存机制详解
- 1. java简介、开发环境搭建、第一个程序
- JAVA Key=Key模型(一对一双向唯一)
- java的四舍五入算法
- Java 将字节数组转化为16进制的多种方案
- Thinking in java 之:内部类的继承
- Java中sleep(),wait(),yield()的区别
- 怎么设置myeclipse的格式化键格式每行的字符长度
- Java多线程系列1(概念和原理)
- Java数据类型和MySql数据类型对应表
- java读取jar包中的资源文件或properties配置文件路径的方法
- 重磅消息:JavaFX官方文档翻译完毕
- 重磅消息:JavaFX官方文档翻译完毕
- 从eclipse到Android studio/迁移eclipse的Android项目到Android studio平台的注意事项
- eclipse导出jar包的问题总结
- MAC下安装多版本JDK和切换几种方式
- 在eclipse中如何查找指定文文件