There is a phenomenon that I misunderstand the method every time even though the method is written on various sites, so I will summarize it myself.
: computer: environment: computer:
$ java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
--Installed Java --How to check Java installed on Mac-- Qiita
$ /System/Library/Frameworks/JavaVM.framework/Versions/A/Commands/java_home -V
Matching Java Virtual Machines (5):
1.8.0_131, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home
1.8.0_45, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
1.7.0_67, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home
1.6.0_65-b14-468, x86_64: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
1.6.0_65-b14-468, i386: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home
Switch the version from "1.8.0_45" to "1.7.0_67".
Add two lines to .bashrc: "JAVA_HOME settings" and "Add JAVA_HOME to PATH".
$ sudo vi .bashrc
Password:{password}
---Vi editor from here------------------------------------------
<Here is the setting I wrote earlier>
export JAVA_HOME=`/System/Library/Frameworks/JavaVM.framework/Versions/A/Commands/java_home -v "1.7"`
PATH=$JAVA_HOME/bin:$PATH
---So far vi editor------------------------------------------
Thank you to this site.
.profile, .bashrc, .zshrc, etc. are fine, but set the environment variable JAVA_HOME using the java_home command. Switch Java version on OS X-Qiita
I always misunderstand "I can't switch: confounded:" without doing this. After writing the configuration file, reloading is basic, isn't it?
$ source ~/.bashrc
Thank you to this site.
After adding it, reload it with source ~ / .bash_profile to switch the version. How to install and switch multiple versions of Java (JDK) using Homebrew on Mac + Update --TASK NOTES
Make sure it is switched.
$ java -version
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
Recommended Posts