In my Java project I have two external dependencies, A and B. I have these as JAR files on my build path. Both project A and B have the external dependency project C. However they rely on different versions of C. If I use the version that's compatible with A, then B breaks, and vice versa.
How to handle this?
Welcome to dependency hell.
Three approaches:
If at least one of the projects A and B is yours, you can try to change the code to reach compatibility with the desired version of C. Ideally, you can update both A and B to the latest stable version of C and "repair" the code to make it work.
If both A and B are external projects, you might experiment with different versions of A and B because they probably rely on different versions of C. Maybe you'll find a combination that works with the same C.
Construct a shaded jar with the Maven shade plugin. Here, you modify the package names of one version of C to make it independent of the other version.