Basically you need to set JAVA_HOME to the correct JRE/JDK that you want to use. It's most probably still set to the Java 24 version.
But setting the JAVA_HOME on macOS can be tricky - simply because you have terminal and GUI processes, and a simple
$ export JAVA_HOME=....
only works on your terminal - not for GUI apps. Even setting this in .profile or .bashrc wouldn't help, as those aren't executed for GUI processes.
So I use an extension, to manage environment variables system wide - including GUI apps.
https://github.com/hschmidt/EnvPane
With this you can set environment variables system wide from the System Settings. For all processes - including GUI apps.
There are other solutions like symlinking the correct Java version as "Current" - but it's tricky.
macOS is using a utility /usr/libexec/java_home
to find the correct Java. And if JAVA_HOME isn't set, it uses the Java that is symlinked as "Current" - which is often/most probably the latest version installed.
That said - the relation of macOS and Java isn't exactly what I would call a good one.
HTH
Daniel