Article From:

Jdk8 has been installed before the installation path:/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk

Now install jdk10, download, double-click the DMG file until the installation is completed, installation path:/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk

After installation, the default JDK is 10. If you don’t want to switch later, you can do so. Otherwise, follow the following steps.


1. Configuring environment variables

1 sudo vi /etc/profile
2 Add the following two lines:3 export JAVA_8_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
4 export JAVA_10_HOME=/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home
6 Note: no JAVA_HOME is specified


Two, set the command to specify JAVA_HOME dynamically

1 alias jdk8='export JAVA_HOME=$JAVA_8_HOME'
2 alias jdk10='export JAVA_HOME=$JAVA_10_HOME'


Three. Execute command switch

Jdk8 is executed at the terminal, and then it switches to java8; when jdk10 is executed, it switches to java10.

Leave a Reply

Your email address will not be published. Required fields are marked *