What is the difference between Class Path and Build Path

后端 未结 6 832
名媛妹妹
名媛妹妹 2020-11-28 18:34

I\'m confused with these two terms.

Also what should I do to create a file under the src folder of a Spring MVC Project? When I create using a File object it create

6条回答
  •  佛祖请我去吃肉
    2020-11-28 19:12

    Classpath (from Wikipedia):

    Similar to the classic dynamic loading behavior, when executing Java programs, the Java Virtual Machine finds and loads classes lazily (it loads the bytecode of a class only when the class is first used). The classpath tells Java where to look in the filesystem for files defining these classes.

    The virtual machine searches for and loads classes in this order:

    bootstrap classes: the classes that are fundamental to the Java Platform (comprising the public classes of the Java Class Library, and the private classes that are necessary for this library to be functional).

    extension classes: packages that are in the extension directory of the JRE or JDK,

    jre/lib/ext/ user-defined packages and libraries

    By default only the packages of the JDK standard API and extension packages are accessible without needing to set where to find them. The path for all user-defined packages and libraries must be set in the command-line (or in the Manifest associated with the Jar file containing the classes).

    Simply put - while your program is running, the JVM loads classes only as needed. When a class is needed, the JVM will depend on the classpath to it know where to load the bytecode from (i.e.: .class files).

    Build path, on the other hand, is typically used by an IDE, such as Eclipse, to know where to look for additional libraries that are required to compile a project's source code. Build path isn't used during runtime.

提交回复
热议问题