Classpath (Java) - Overview and Architecture

Overview and Architecture

See also: Java Classloader

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 this 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:

  1. 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).
  2. extension classes: packages that are in the extension directory of the JRE or JDK, jre/lib/ext/
  3. 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).

Read more about this topic:  Classpath (Java)

Famous quotes containing the word architecture:

    Art is a jealous mistress, and if a man have a genius for painting, poetry, music, architecture or philosophy, he makes a bad husband and an ill provider, and should be wise in season and not fetter himself with duties which will embitter his days and spoil him for his proper work.
    Ralph Waldo Emerson (1803–1882)