This can also happen when you upgrade to say, java 17 from java 8 and you don't have JAVA_HOME set. In my case, because I used to use jenv to manage my JDKs and it doesn't work via JAVA_HOME, it would fail with the same error.