1

I downloaded Java 8 from oracle.com, and I installed it. Nothing unusual. But when I type java I get: No Java runtime present, requesting install. And if I go to settings the java icon is there!

IconDaemon
  • 19,234

1 Answers1

0

I recommend using jenv and Homebrew together to manage Java installations and environments, especially as you're working from the command line.

Install jenv

brew install jenv

Then install the java version you want, Java 8 is annoying bc it's not in Homebrew itself anymore, but this works

brew cask install adoptopenjdk/openjdk/adoptopenjdk8

Then add it to jenv

jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

Then set it as the global java

jenv global 1.8

Now java -version is

openjdk version "1.8.0_242"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.242-b08, mixed mode)

jenv has been very useful to me as a Java developer for managing and switching between all my different Java versions. It also conveniently lets you set versions specific to projects/directories with jenv local

minseong
  • 8,824
  • /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home is not a valid path to java installation – MANGUSTA Nobody Feb 22 '20 at 13:43
  • at the second step : Failure while executing; git clone https://github.com/adoptopenjdk/homebrew-openjdk /usr/local/Homebrew/Library/Taps/adoptopenjdk/homebrew-openjdk --depth=1 exited with 128. – MANGUSTA Nobody Feb 22 '20 at 13:45