When I tried it again today, everything worked just fine. I suspect that all I had to do was reboot my MacBook so some environment variable changes could take effect. I'm not sure which ones. I had updated my .zprofile to set JAVA_HOME and the PATH after I installed JDK 21 like this and restarted the console:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-21.0.8+9
PATH=$JAVA_HOME/bin:$PATH
But maybe I needed to log out of Mac OS and sign back in for the settings to be recognized by Studio Pro. If I know more about what happened, I'll post it.