'JAVA SDK not found error in unity 2021 and tells to install from unityhub but on unity hub it shows it is installed

I am using Unity 2021.3.0f1 on ubuntu 20.04 and getting error:

UnityException: JDK not found
Java Development Kit (JDK) directory is not set or invalid. Please, fix it in Edit / Unity -> Preferences -> External Tools
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) (at /home/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)

but when I try to install through unityhub it shows that jdk is installed (Check screen shot below) .

unity

so how can I reinstall it.

thank you in advance for helping me out



Solution 1:[1]

I would give this forum post a read. If you are new to Unity and haven't been to the Unity forums, that's usually a better place to get help for debugging Unity problems.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 charles-mersereau