I’ve always taken the classpath for granted, i.e. – its something that eclipse, maven , ant , etc handled for me. Its obvious that the classpath is the place where java “looks” for binary classes which are executed / integrated with an application.
However, there are some intricacies which are not clearly described.
1) How does java “find” classes in the classpath ?
2) How are collisions handled by javac when looking into the classpath ?
3) What is happening “under the hood” when tools like maven/ant add/ignore elements to the classpath ? Do these tools simply wrap the javac program ?
4) Finally : is there an example of a “manual” complicated build for java, that doesnt use the modern generation of build tools — just for educational purposes — which is available ?
Class location is just hierarchical by fully-qualified name. Getting the byte stream depends on the backing store, whether it’s on the filesystem (just reads the file), in a jar (reads the zip entry), in a DB (gets the bytes). It’s up to the classloader to translate the FQN to the byte stream.
Implementation-dependent. Generally first on the classpath wins, but that’s not a requirement, it’s just the easiest.
More or less.
You mean like an old
Makefile-based one? Or a big ol’ Ant one? Not sure what you’re asking. It’s mostly building up classpaths, which is easy, and creating artifacts.