在 JDK 1.0 到 1.8 版中设置 java 类路径:-cp vs -classpath?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17157074/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-01 01:10:38  来源:igfitidea点击:

Setting the java classpath: -cp vs -classpath in JDK versions 1.0 through 1.8?

javaclasspath

提问by Daniel

I've been looking at compiling and running Java programs from the command line and I keep seeing different versions of setting the classpath: -cpvs -classpath. I want to think these are identical but can someone more knowledgeable than me confirm or refute this?

我一直在研究从命令行编译和运行 Java 程序,我一直看到设置类路径的不同版本:-cpvs -classpath。我想认为这些是相同的,但比我更有见识的人能否证实或反驳这一点?

采纳答案by Pshemo

You can easily find answer by checking official documentation. From Windowsor Unixversions:

您可以通过查看官方文档轻松找到答案。从WindowsUnix版本:

The javacommand has a -cpoption that is an abbreviationfor -classpath.

java命令有一个-cp选项是缩写-classpath

回答by austin

They are the same. Do java -helpto see all the options. -cp and -classpathdo the same thing.

他们是一样的。执行java -help以查看所有选项。-cp and -classpath做同样的事。