Differences between classpath and sourcepath options of javac

前端 未结 4 1626
甜味超标
甜味超标 2020-11-30 03:35

I read the Sun documentation and a lot of posts on Stack Overflow, but I\'m still confused about the differences between the Java compiler options -cp and

4条回答
  •  心在旅途
    2020-11-30 04:26

    • classpath is searched for class (.class) files
    • sourcepath is searched for source (.java) files (.a.k.a class or interface definitions)

    However, if sourcepath is NOT specified, the classpath is searched for both class files AND source files.

    This leads me to believe that we can almost always keep things simple by using just classpath, and by avoiding sourcepath altogether.

    People who need to use both classpath and sourcepath are probably targeting strange directory contents. For example, they might have a folder that contains source files and class files, but only want to have the source files searched for.

提交回复
热议问题