How to use multiple java version

I want to use both Jdk 11 & Jdk 17 for different jobs.
I have configured Jdk17 in Global Tools Configuration/JDK installations.
Also, I have mentioned JDK in my jenkins file as below
tools {
jdk ‘JDK17’
ant ‘commerce-ant’
I am setting java home too
sh “export JAVA_HOME=/var/jenkins_home/tools/hudson.model.JDK/JDK17/jdk-17 && export PATH=/var/jenkins_home/tools/hudson.model.JDK/JDK17/jdk-17/bin:${PLATFORM_HOME}/apache-ant/bin:$PATH && export ANT_OPTS=‘-Xmx2g -Dfile.encoding=UTF-8’”
But after everything it is throwing error while running job.

We cannot run Java, please ensure you have Java installed.

[2023-01-08T08:36:57.075Z] We have tried to execute /var/jenkins_home/tools/hudson.model.JDK/JDK17/jdk-17/bin/java but failed.

[2023-01-08T08:36:57.075Z] If you have installed Java in a unusual place you can set JAVA_HOME

[2023-01-08T08:36:57.075Z] to the directory containing the Java installation.

That tells you that you need to look at the agent trying to run the program and understand why it failed to run /var/jenkins_home/tools/hudson.model.JDK/JDK17/jdk-17/bin/java. It may be that there is no program in that location. It may be that there is a Windows program on a Linux computer. It may be one of many different failures that you can investigate.