After installing Java in mac you can set the java home variable like below
Open besh profile
open -a TextEdit ~/.bash_profile
Set Java home
Now after making above entries in bash profile save the file and close it.
You can also refer below link
Please try the same and let me know if you face any further issue.