You should install the most recent Jenkins LTS and either Java 17 or Java 21, configure an agent that runs either Java 17 or Java 21 to match the Java version you’re using with the Jenkins controller, then configure a JDK tool that will provide Java 8 on the agent. Your jobs can then be configured to build and test with Java 8.
More details are available from How to upgrade agents to java 17, but keep java version for builds at java 8, 11, ..? - #2 by MarkEWaite