How to install Java using terminal? I want to install Java entirely from the terminal without using any GUI. Can anybody give some instructions? I know that I download it with curl, but it seems that curl doesn't play quite nicely with Oracle, and I have no idea what to do after downloading it.

Edit: I want to use Oracle's JDK
The best/safest way to install Java on macOS is with Homebrew; just type this:
brew cask install java

Or if you don’t have Homebrew installed already, just type this command first:
/usr/bin/ruby -e &quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&quot;
brew cask install java