JDK8 has been installed before, installation path:/library/java/javavirtualmachines/jdk1.8.0_144.jdk
now install JDK10, after downloading, double-click the DMG file until the installation is complete, install the path: /LIBRARY/JAVA/JAVAVIRTUALMACHINES/JDK-10.0.1.JDK
After the installation is complete, the default JDK is already 10, so if you don't want to switch later, you can do so. Otherwise, perform the following steps.
I. Configuring Environment variables
1 sudo vi/etc/profile2 Add the following two lines:3 export java_8_home=/library/java/ javavirtualmachines/jdk1.8.0_144.jdk/contents/Home4 Export java_10_home=/library/java/ javavirtualmachines/jdk-10.0.1.jdk/contents/Home56 Note: no Java_home specified
Second, dynamically set the command to specify Java_home
1 alias jdk8= ' export java_home= $JAVA _8_home '2 alias jdk10= ' export java_home= $JAVA _10_home '
Third, perform the command switch
Execute JDK8 at terminal, switch to Java8 now, execute jdk10, switch to JAVA10.
Installation and management of multiple versions of JDK 2.1 mac