As @tech_android already posted in this comment, to solve that problem permanently, go to Module Settings >
SDK Location >
Use embedded JDK.
This will remove dependency on the external Java installation by using the embedded JDK.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…