For Ubuntu 24.04 where Android Studio 2024.1.1 is installed through Snap Store, the JAVA_HOME value should be like the following:
export JAVA_HOME=/snap/android-studio/current/jbr