The classpath and the classloader

Java was designed to be modular and for that it needs some way to load your code easily. The answer to this was the classloader, the classloader allows you to read resources from every entry of the classpath; you can look at resources in the classpath as a hierarchical structure similar to the file system.

The classloader is just a list of entries; each entry can be a directory in the filesystem or a JAR file. At this point, you should also know that JAR files are just zip files.

The classloader will treat each entry as a directory (JAR files are just zipped directories) and it will look for files in each directory.

There are a lot of concepts here to remember, let's try to summarize them:

  • JAR files are ZIP files; ...

Get Clojure: High Performance JVM Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.