Don’t rely on Oracle to install Java properly on your mac.
Use HomeBrew.
brew tap caskroom/cask
brew install brew-cask
If you get the error “already installed”, follow the instructions to unlink it, then install again:
brew unlink brew-cask
brew install brew-cask
And then finally:
brew cask install java