Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change java version in macOS BigSur

I can't change the java version in macOS BigSur. i have the following versions :

when I execute this command

/usr/libexec/java_home -V

i have the following versions :

Matching Java Virtual Machines (3):
    11.0.8 (x86_64) "Oracle Corporation" - "Java SE 11.0.8" /Library/Java/JavaVirtualMachines/jdk-11.0.8.jdk/Contents/Home
    1.8.261.12 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
    1.8.0_261 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_261.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk-11.0.8.jdk/Contents/Home

i want to switch to java 1.8 as the default one , so I execute this command :

export JAVA_HOME=/usr/libexec/java_home -v 1.8.0_261

and then when I check java version :

java -version

I still got the old (higher one)

java version "11.0.8" 2020-07-14 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.8+10-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.8+10-LTS, mixed mode)

why it's not working?

like image 696
leonidas79 Avatar asked Sep 25 '20 10:09

leonidas79


1 Answers

Please use below command :-

export JAVA_HOME=`/usr/libexec/java_home -v 1.8.0_261`
like image 126
Madhurish Gupta Avatar answered Oct 02 '22 15:10

Madhurish Gupta