Since September 2017 Oracle started releasing new Java language version every 6 months. Of course many versions are non-LTS and I used them only to check out new language features. Last year Java 17 was released (LTS release) and it’s getting more and more adoption.
At my work I usually work with many projects each opened in separate IntelliJ IDEA window. It’s pretty common when you work with microservices. Because each service is maintained by different team it is not unusual that one service is using Java 11 and other requires Java 17.
To install and manage many versions of JDK I prefer to use SDKMAN! (sdkman.io). It manages not only Java SDK but also other language SDKs like Scala, Kotlin. No need to look for new tool or learn how to use them.
How to install SDKMAN is explained on its website so I skip this part. If you haven’t already done that install at least two versions of JDK from distribution you prefer. For example:
➜ sdk install java 11.0.16.1-zulu
➜ sdk install java 17.0.4.1-zulu

If you installed Oh my zsh you can enter for example sdk install java 17<TAB><TAB> and all matching versions will be displayed and you can choose one with arrow keys.
Once you have everything installed, switch directory to your java project. Then select proper java runtime version using sdk command:
➜ sdk use java 11.0.16.1-zulu
Next use sdk env init command to remember which java version should be used with this project. This will create .sdkmanrc in current directory with with preferred version of JDK. Every time you issue sdk env command in this directory valid java version will be selected.
➜ sdk env init
.sdkmanrc created.
➜ cat .sdkmanrc
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
java=11.0.16.1-zulu
➜ sdk env
Using java version 11.0.16.1-zulu in this shell.
It is also worth noting that .sdkmanrc file can have more than one preference defined. For example you can change versions of java and gradle at once.