Zend certified PHP/Magento developer

Not able to switch Java version to Java 17

I have installed Amazon Corretto Java 17 from here.

However, I am not able to switch the Java version to Java 17.

Following are the steps I have already tried:

1.

export JAVA_HOME=`/usr/libexec/java_home -v17`
  1. export JAVA_HOME=/Library/Java/JavaVirtualMachines/amazon-corretto-17.jdk/Contents/Home
  2. I have also check the highest version of Java using below command:
    /usr/libexec/java_home and it shows correct Java 17 version:
    /Library/Java/JavaVirtualMachines/amazon-corretto-17.jdk/Contents/Home
  3. I have also checked all the versions of Java installed on my machine using command /usr/libexec/java_home -V and it correctly shows Java 8, 11, and 17:
17.0.1 (x86_64) "Amazon.com Inc." - "Amazon Corretto 17" /Library/Java/JavaVirtualMachines/amazon-corretto-17.jdk/Contents/Home

11.0.9.1 (x86_64) "Amazon.com Inc." - "Amazon Corretto 11" /Users/harsh.pamnani/Library/Java/JavaVirtualMachines/corretto-11.0.9.1/Contents/Home

1.8.0_275 (x86_64) "Amazon" - "Amazon Corretto 8" /Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/amazon-corretto-17.jdk/Contents/Home
  1. I also added JAVA_HOME exports mentioned in step-1 and step-2 to .zshrc and .bash_profile as well.
  2. I have followed multiple questions on StackOverflow and multiple
    blogs as well. For example,

How to set or change the default Java (JDK) version on macOS?

switch java version on mac OS

https://java.tutorials24x7.com/blog/how-to-switch-java-version-on-mac

https://www.lotharschulz.info/2019/08/21/mac-change-default-java-version

https://akrabat.com/using-jenv-to-select-java-version-on-macos/

https://www.happycoders.eu/java/how-to-switch-multiple-java-versions-windows/

  1. I am using jenv to switch between different java versions. Even jenv is not able to find Java 17. I used jenv versions and following is the output:
system
  1.8
  1.8.0.275
  11
  11.0
* 11.0.9.1 (set by /Users/harsh.pamnani/.jenv/version)
  corretto64-1.8.0.275
  corretto64-11.0.9.1

Even after following all the steps above when I do java --version, it is still set to Java 11:

openjdk 11.0.9.1 2020-11-04 LTS
OpenJDK Runtime Environment Corretto-11.0.9.12.1 (build 11.0.9.1+12-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.9.12.1 (build 11.0.9.1+12-LTS, mixed mode)

Could someone please help me understand if I am missing anything here. Thank you.