homebrew-openjdk icon indicating copy to clipboard operation
homebrew-openjdk copied to clipboard

Problem with switching between different JDK version on Mac Big Sur

Open Fuddi opened this issue 3 years ago • 6 comments

Solution: Adding the command unset JAVA_HOME to the jdk function like this answer suggest: https://stackoverflow.com/a/64917842/2315666

Fuddi avatar Dec 14 '20 11:12 Fuddi

Please file a bug report on https://feedbackassistant.apple.com/. I don't have Big Sur, so I cannot reproduce the problem myself.

aahlenst avatar Dec 15 '20 07:12 aahlenst

+1 to both the issue and @Fuddi's solution on 11.1

@aahlenst @karianna You guys think waiting on Apple is a valid solution here?

replygirl avatar Dec 16 '20 21:12 replygirl

Urging Apple to fix by bombarding them with radars is a valid solution. I'm not looking forward to rollout an otherwise unnecessary fix to a large fleet of Macs and CI pipelines.

aahlenst avatar Dec 16 '20 21:12 aahlenst

@gdams will make a doc change here

karianna avatar Jan 25 '21 11:01 karianna

I'm still pretty bad at this whole java_home thing. I feel like it makes no sense. Sorry for being a noob. But I'm leaving this here in case anyone uses big sur and wants a simple copy paste for what to put in .zshrc (default on big sur)

# Change 14 to your installed version to be considered "default" on machine boot up
export JAVA_HOME=`/usr/libexec/java_home -v 14`

jdk() {
        unset JAVA_HOME
        version=$1
        export JAVA_HOME=$(/usr/libexec/java_home -v"$version");
        java -version
 }

Let me know if I'm doing something wrong. I'm new to this.

ColtonIdle avatar Mar 02 '21 21:03 ColtonIdle

This is working for Big Sur 11.2.3.

Greetings

 jdk() {
        unset JAVA_HOME
        version=$1
        export JAVA_HOME=$(/usr/libexec/java_home -v "$version");
        export PATH=$JAVA_HOME/bin:$PATH
        java -version
 }

ercan-akar avatar Mar 23 '21 20:03 ercan-akar