On Thu, 16 Oct 2025 at 08:26, Gilles Sadowski <[email protected]> wrote: > > Hello. > > Le jeu. 16 oct. 2025 à 08:26, s rbk <[email protected]> a écrit : > > > > Hi, > > Can we have different versions of apache commons libraries in the same > > application? > > Usually yes: Incompatible versions are delivered in different java "top-level" > packages (suffixed by the version's major number). IOW, you can always call > functionality from different major versions in the same application.
We also change the Maven coordinates so Maven allows both in the same classpath [1] > We strive to ensure binary compatibility between minor versions, so multiple > versions can also be used together, but application behaviour can change > depending on which version came on top in the classpath... However, this is not recommended (and AFAIK Maven does not allow it). An upwards compatible jar may potentially contain mutually dependent internal changes to several classes. The only sure way to ensure that all mutually dependent classes are loaded from the same jar is to ensure there is only a single copy of each on the classpath. This is inherent to the way the Java classpath works. There are ways to get around this (OSGI etc.), but they rely on ensuring that there is a single copy of each class on the classpath, e.g by using multiple classpaths which are swapped in and out as needed. What are you trying to achieve? Sebb [1] https://cwiki.apache.org/confluence/display/COMMONS/MavenAndClasspath > Regards, > Gilles > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
