Make sure that the JAVA_HOME environment variable points directly to your JDK installation folder like:
C:\Program Files\Java\jdk-17
(not to the bin folder)
After updating it, restart your terminal or IDE and try again.