Android-build-tools can't find JDK

Problem with installing android-build-tools on Mac.

running java -version returns:

java version "22.0.1" 2024-04-16
Java(TM) SE Runtime Environment (build 22.0.1+8-16)
Java HotSpot(TM) 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)

javac -version returns:
javac 22.0.1

Is there any workaround to this? I also install openjdk using brew, temurin and version 21 from Oracle website, but still the same issue. I want to make sure this is resolved before I commit fully to Fuse, coming from Flutter and trying something new (used to develop apps using Fuse).