OS:macOS Catalina 10.15.5 brew:2.4.3
If you use brew cask as it is, you cannot install an old version of Java. Therefore, use the following command to install older versions as well.
$ brew tap homebrew/cask-versions
Install various versions
//Check the installable java version
$ brew search java
// java14
$ brew cask install java
// java11
$ brew cask install java11
// java8
$ brew cask install adoptopenjdk8
//Java version check
$ /usr/libexec/java_home -V
anyenv can manage * env. In this case, it is installed to manage jenv.
//Install anyenv with brew
$ brew install anyenv
//Path added zsh version
$ echo 'eval "$(anyenv init -)"' >> ~/.zshrc
//Manifest directory creation
$ anyenv install --init
with this.The anyenv directory is created.
//SHELL restart
$ exec $SHELL -l
//anyenv command
//Installed*env version check
$ anyenv versions
//Can be installed with anyenv*List of env
$ anyenv install -l
source ~ / .zshrc
to reflect them.The plugin is optional, but it is convenient to include it.
//Create directory for plugins
$ mkdir -p ~/.anyenv/plugins
// anyenv-I put it in update anyenv*A plugin that updates env in bulk
$ git clone https://github.com/znz/anyenv-update.git ~/.anyenv/plugins/anyenv-update
// anyenv-I put it in git anyenv*Plugin that can execute env with git command
$ git clone https://github.com/znz/anyenv-git.git ~/.anyenv/plugins/anyenv-git
Manage Java installed with cask
//install jenv
$ anyenv install jenv
//SHELL restart
$ exec $SHELL -l
//Verification
$ anyenv versions
jenv:
system
1.8
1.8.0.252
11
11.0
11.0.2
14
14.0
* 14.0.1 (set by /Users/masa/.anyenv/envs/jenv/version)
openjdk64-1.8.0.252
openjdk64-11.0.2
openjdk64-14.0.1
It is a method to register various Java versions in jenv and switch.
//Add to the associated jenv
$ jenv add `/usr/libexec/java_home -v "1.8"`
$ jenv add `/usr/libexec/java_home -v "11"`
$ jenv add `/usr/libexec/java_home -v "14"`
//Check the version of java managed by jenv
$ jenv versions
//global setting
$ jenv global 11.0.2
//Java version check
$ java versions
//Shell launch
$ jenv exec zsh
// JAVA_Set HOME automatically
$ jenv enable-plugin export
// JAVA_HOME confirmation
$ echo $JAVA_HOME
//Topic When using another version of JDK in a specific directory
$ jenv local 11.0.2
Recommended Posts