posted 14 years ago
1>Why the develpers use different versions of jar is this a mistake or if not then what purpose different versions of the same jar solves?
I don't know what do you mean.
2> Why not there is a single class loader for all it will solve all the problem?
JVM use different classloaders for different reason: 1) the different way classes are loaded (system, *.class, *.jar or from network), 2) different class loader allows different access permission to be handled (in most case), 3) allows classes access to be heiratically organized and 4) ALLOWS different version of the same class to be loaded.
3>Class loaders are .class files then who loads the class loaders?
Class loader is a class that can load other classes.
4>The class not found exception that shows up basically means the class is found but the definition of the class doesn't match with what is searched for, may be because of different versions of the class some newly introduced methods or constants are not available in the class that is loaded. Am I right?
ClassNotFoundException is thrown when the bytecode of the class is not found.
About the different versions of a class. there is simple rule:
Within a class loader, all classes must have a unique full names.
So as soon as different versions of a class is not loaded by the same Classloader, it is possible to have two of them around in a running JVM. Keep in mind that, when that situation happens, a client class can only access to a version of the class (depending on what Classloader it ask).
Hope this helps.
NawaMan