Are Java classpaths the first on the first lookup?

I have a question about Java Class path variables.

If I have multiple jars with the same classes using jvm at runtime. Is the first in the classpath last, or undefined?

thank

+2


source to share


1 answer


This is the first one found. See Java Tip 105: Mastering the Classpath with JWhich :

Of particular importance and a lot of horror, the classloader will load classes in the order they appear in the classpath. Starting at firstpathpath, the loader class visits each specified directory or archive file trying to find a class to load. The first class is found with its own name, loaded, and any remaining entries in the class are ignored.



In practice, this can get complicated after you start putting a few classloaders into the mix, but first things first.

+5


source







All Articles