I would like to get deeper understanding on how Java deals with different versions of Classes/Packages/etc., but couldn't find any resources or at least the best way to google for it. The problem is as follows.
Imagine we have some external package com.external.package
that contains a definition of SomeInterface
.
Now I write a java class MyClass
that implements SomeInterface
, and using com.external.package v1.0.0
. Next I package a (lean) jar containing MyClass
.
Now I plug this jar in another program that is looking for implementations of SomeInterface
, but in it's dependencies, it is using com.external.package v2.0.0
.
Is the reason I get Failed to find any class that implements SomeInterface
that versions of SomeInterface
don't match in the program and in the jar that contains a class extending it?
Basically the question I would like to find an answer for is what info do jars store regarding external dependencies? Does it store the exact versions of them and if they don't match at the runtime it complains? But why does it even allow running the program with references to same dependency, but different versions?