How to install JDK8 and JDK17 at the same time on MAC M1

background

The author originally installed JDK8 on the computer. Since MAT is needed, MAT supports MAC m1 only compatible with JDK17 and above versions, so JDK17 needs to be installed, and it is hereby recorded.

download

First, download JDK17 from the oracle official website: https://www.oracle.com/java/technologies/downloads/#java17
insert image description here

Install

JDK is installed in the /Library/Java directory by default. Open the Finder and go directly to the file through shift+command+g. If the installation is successful, there will be two JDKs in the /Library/Java/JavaVirtualMachines directory:

insert image description here

configuration

Next, open the terminal, enter vim ~/.bash_profile , and edit the configuration file.
In the configuration file, configure the following content:
insert image description here
input is complete, press the esc key, enter: wq to save and exit, and then execute the command: source ~/.bash_profile

version switching

Next, you can switch between multiple versions:
insert image description here

Guess you like

Origin blog.csdn.net/weixin_43589025/article/details/129941848