MacOS uninstalls Java 9 and uses Homebrew to build and configure the Java Development Environment. java9homebrew
Install Homebrew (software package management tool under macOS:
/Usr/bin/ruby-e "$ (curl-fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" // enter this command in the terminal
Homebrew is used for the following installation:
Install Java:
Brew cask install java // The latest Java9 command is installed. What I need is Java8 ......
Uninstall Java 9:
Ls/Library/Java/JavaVirtualMachines // view jdk version // uninstall sudo rm-rf/Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk // here 9.0.1 is The sudo rm -fr/Library/Internet \ Plug-Ins/JavaAppletPlugin. plugin sudo rm-fr/Library/PreferencePanes/JavaControlPanel. prefPane sudo rm-fr ~ /Library/Application \ Support/Java
Install Java 8:
brew tap caskroom/versionsbrew cask install java8
Install eclipse:
brew cask install eclipse-ide
Configure Java environment variables:
/Usr/libexec/java_home // locate JAVA_HOME location Matching Java Virtual Machines (1): 1.8.0 _ 121, x86_64: "Java SE 8"/Library/Java/JavaVirtualMachines/jdk1.8.0 _ 152.jdk/ Contents/Homevi ~ /. Bash_profile // edit the profile file // press the I key and enter the following code JAVA_HOME =/Library/Java/JavaVirtualMachines/jdk1.8.0 _ 152.jdk/ Contents/HomePATH = $ JAVA_HOME/bin: $ PATHCLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar // then Press esc and enter: wq to save and exit the profile file.
Then run:
source ~/.base_profile echo ~/.base_profile
Check whether the environment variable is configured successfully:
$ echo $JAVA_HOME/Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home