classpath和sourcepath之间的区别?

时间:2014-06-28 19:18:27

标签: java

我对classpath和sourcepath有这种困惑。我已经提到了这些链接 我也是正确的。 参考 -

Differences between classpath and sourcepath options of javac

-sourcepath vs -classpath

Regarding automatic recompilation, I can't spot the difference between javac's -classpath and -sourcepath options

这是否意味着如果我们不编辑源文件,classpath和sourcepath都不会被重新编译? 具体来说,这条线困扰了我! 请注意,如果找到了源,则通过类路径找到的类会自动重新编译。 任何人都可以用简单的语言用简单的例子来解释这个问题吗?这会有很大的帮助!

2 个答案:

答案 0 :(得分:4)

sourcepath是您正在编译的源的路径。

类路径是您要编译的库的路径(或多个路径)。这些是编译类,可以在文件夹或Jar文件中。

答案 1 :(得分:0)

Sourcepath告诉javac从哪里获取源代码。 Classpath告诉javac在哪里获取允许源代码编译的其他类文件。