If somebody come to this post looking for solution on Windows OS please follow
https://www.mkyong.com/java/how-to-set-java_home-on-windows-10/
On side note, I will recommend to use Mac OS for appium related automation; itโs best suited for mobile automation and will surely give much less headaches
Regards,
Vikram