本文基于WindowsXP平台JDK的环境变量配置
首先,要先准备好JDK,本文基于jdk1.6.0_25版本。如果你还没有下载java JDK,请到java官网下载。
其次,就是安装JDK了,安装过程中可以自定义安装目录等信息,例如我选择安装目录为D:\Application\Java\jdk1.6.0_25。
最后,安装完JDK就是剩下配置环境变量了。配置步骤如下:
1、安装完成后,右击“我的电脑”,点击“属性”;
2、选择“高级系统设置”选项卡,点击“环境变量”;
3、在“系统变量”中,设置3项属性,JAVA_HOME,PATH,CLASSPATH(不区分大小写),若已存在则点击“编辑”,不存在则点击“新建”;
4、JAVA_HOME指明JDK安装路径,就是刚才安装时所选择的路径“D:\Application\Java\jdk1.6.0_25”,此路径下包括lib,bin,jre等文件夹(此变量最好设置,因为以后运行tomcat,eclipse等都需要此变量);
5、Path使得系统可以在任何路径下识别java命令,设为:“%JAVA_HOME%/bin;%JAVA_HOME%/jre/bin”
6、CLASSPATH为java加载类路径,只有类在classpath中,java命令才能识别,设为:“.;%JAVA_HOME%/lib/dt.jar;%JAVA_HOME%/lib/tools.jar ”
%JAVA_HOME%就是引用前面指定的JAVA_HOME;
7、单击“开始”->;“运行”,键入“cmd”;
8、键入命令“java -version”,“java”,“javac”几个命令,出现画面,说明环境变量配置成功;