If the same class is in two more jars, the problem should be.
What do you mean? Why should be a problem?
In such scenarios, which class is the program importing? (Class with old timestamp?)
If the class exists in two JARs, the class will be loaded from the first JAR in the class path where it is found. Citation Setting the class path (the cited part also applies to archive files):
Important is the order in which you specify multiple path path entries. The Java interpreter will search for classes in directories in the order they appear in the class path variable. In the above example, the Java interpreter first looks for the desired class in the C:\java\MyClasses . Only if he does not find a class with his own name in this directory, the interpreter will look in the C:\java\OtherClasses .
In other words, if a specific order is required, simply list the JAR files explicitly in the class path. This is what is commonly used by application server providers: to fix certain product classes, you put a JAR (for example, CR1234.jar ) containing the corrected classes (classes) in the class path to the main JAR (say weblogic.jar ).
What methods can we follow to avoid such complications.
Well, the obvious answer is not to do this (or just as intended, as in the above example).
source share