How does the java compiler find the class files whereas the classpath is not set to the jdk path?

后端 未结 2 1408
渐次进展
渐次进展 2021-01-12 07:49

I\'m trying to look under the hood about java compilation. So I put my IDE away and started using MS-DOS command-line...

I created a simple project, as described in

2条回答
  •  孤街浪徒
    2021-01-12 08:43

    The classpath variable doesn't do what you think. To cite the oracle documentation:

    The CLASSPATH variable is one way to tell applications, including the JDK tools, where to look for user classes. (Classes that are part of the JRE, JDK platform, and extensions should be defined through other means, such as the bootstrap class path or the extensions directory.)

    Source: http://docs.oracle.com/javase/tutorial/essential/environment/paths.html

    Basically since java.lang.* is part of the platform and delivered with the JDK/JRE, the compiler doesn't have to be told by you where to look for them.

提交回复
热议问题