current directory(当前目录): 当前在用的目录就是当前目录。比如说当你打开NOTEPAD,并处于运行状态时候,当前目录就是c:/windows;如果你用cmd命令打开命令行窗口,当前目录就是c:/windows/system32;如果你在用java这条指令,当前目录就是JAVA下的BIN目录所在的路径,因为java.exe在bin里面。 在java开发配置环境变量时,系统默认(我们对classpath不做任何设定时)的路径也是当前目录。
CLASSPATH: CLASSPATH是专门针对java的,它相当于windows的path;path是针对整个windows的。 CLASSPATH告诉java虚拟机(jvm)要使用或执行的*.class文件放在什么地方。 所谓的JVM就好像是在微软OS上面再激活另外一个OS,对JVM来说CLASSPATH就好像是对微软OS来说的PATH,所以要用jvm开运行程序就需要设定classpath,然而jvm像windows一样它也有个默认的查找class文件的路径,对刚开始学习java的我们来说,默认的已经够我们用了,那就是当前路径,因此不设置classpath也可以。 在windows中 classpath 大小写没有关系,其他的环境变量名称也一样。 参照: http://java.sun.com/javase/6/docs/technotes/tools/windows/classpath.html The class path is the path that the Java runtime environment searches for classes and other resource files. The class search path (more commonly known by the shorter name, "class path") can be set using either the -classpath option when calling a JDK tool (the preferred method) or by setting the CLASSPATH environment variable. The -classpath option is preferred because you can set it individually for each application without affecting other applications and without other applications modifying its value. 如果你在classpath中用到 other resource files,那说明你已经熟悉classpath了,你可以自己随意设置。 The default class path is the current directory. Setting the CLASSPATH variable or using the -classpath command-line option overrides that default, so if you want to include the current directory in the search path, you must include "." in the new settings.-----这句话是说,当我们不设定classpath时,系统默认的classpath是当前目录,如果你个人想设置classpath的话,那么务必在classpath中加入".",这个英文状态下的点就表示当前目录。 至于classpath中要不要加入其他的路径(包括文件目录、包的根目录等),这要看开发的需要,一般我们初学者是用不到的。