Download jdk 8 from this link after accepting the Agreement Terms. Open dmg and follow through the setup process. Check if java is installed properly by running
$ java -version
Python
$ brew install python@3
# check if python and pip both are pointing to version 3
$ pip install virtualenv