

Chances are you don't have to destroy the other Java version with the same version number: if MacOS finds a Java version matching the requested version number, it stops looking for other versions. When you need it again, you must restore the Contents folder. That's a fairly reliable way to convince MacOS to ignore that Java installation. you're not interested in, and rename the Contents folder. Image published at under a CC0 license by an unknown artist. Navigate to the folder /Library/Java/JavaVirtualMachines, cd into the Java version Selecting a Java version. The only solution I found to do so is using brute force. You can't easily switch between GraalVM 11.0.9 and AdoptOpenJDK 11.0.9. That's not as arcane as it sounds: MacOS treats GraalVM as just another Java distribution. The bad news is you can't switch between identical versions provided by different vendors. Replacing 15.0.1 with 15 does the trick, too, unless you want to distinguish between, say, 15.0.1 and 15.2.0. It doesn't have to be the precise version number. The catch is you have to unset (sic!) the JAVA_HOME variable. In a way, it's a good idea: just set the version number, and the operation system does the rest for you. Most of the time setting the PATH and JAVA_HOME worked. Older versions of OSX were pretty straightforward. However, if you need to switch between different versions, it doesn't suffice to set the environment variables PATH and JAVA_HOME. That's not a big deal if you need only one version of Java. Nowadays, most operating systems make a developer's life difficult by trying to help. Once upon a time, you could use Java without installing it.
