将-classpath选项与java一起使用时,是否会添加或替换CLASSPATH环境变量的内容?
发布于 2010-01-29 22:13:05
使用classpath变量,它会覆盖环境变量的CLASSPATH,但仅限于该会话。如果重新启动应用程序,则需要再次设置类路径变量。
发布于 2010-01-29 19:11:52
是。引用自java(1)手册页:
-classpath classpath
-cp classpath
Specifies a list of directories, JAR archives, and ZIP archives to search for class files. Class
path entries are separated by colons (:). Specifying -classpath or -cp overrides any setting of the
CLASSPATH environment variable.
If -classpath and -cp are not used and CLASSPATH is not set, the user class path consists of the cur-
rent directory (.).发布于 2010-01-29 19:12:15
使用其中一个选项,而不是两个都使用。
指定-classpath或-cp将覆盖CLASSPATH环境变量的任何设置。
..。
-classpath选项是首选选项,因为您可以为每个应用程序单独设置它,而不会影响其他应用程序,也不需要其他应用程序修改其值。
..。
设置CLASSPATH变量或使用-classpath命令行选项的
会覆盖该缺省值,因此如果要在搜索路径中包含当前目录,则必须包含".“在新设置中。
https://stackoverflow.com/questions/2161468
复制相似问题