How to use different Java versions for main and test in Maven

Introduction In this article, we are going to see how we can use different Java versions for the main and test folders in Maven so that you can run tests on a newer version of Java.