Home > Software engineering >  Java19 to java 17 lts in mac M1 using brew
Java19 to java 17 lts in mac M1 using brew

Time:12-15

I installed openjdk19 by brew install java

I want to uninstall this version and reinstall openjdk 17 lts version

how to do that?

CodePudding user response:

to uninstall package you can use one of the commands: brew uninstall packageName in your case:

brew uninstall java

The remove Homebrew package command looks like this: brew remove packageName in your case:

brew remove java

To install java 17, it is necessary to add version: brew install openjdk@17

Here is brew documentation how to do it: Homebrew doc And also there is answer how to install Java 17 : macOS - How to install Java 17

CodePudding user response:

what Rustam suggested you is the right thing. I wanted to add that you can use jenv for having more than one java installed and easy switching of the java versions instead of removing it. You can setup global or local (folder specific) java version. You can find more information here https://www.jenv.be/ Basically

brew install jenv
echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(jenv init -)"' >> ~/.zshrc

List the versions you have

jenv versions
  system
  1.8
  17.0
* 11.0
  11.0.11
  openjdk64-1.8.0.292
  openjdk64-17.0.11

After that you can choose one from the installed using this command

jenv global openjdk64-17.0.11
  • Related