Java snap application is not able to play sounds (core24)

Have a look here:

In summary, Java is attempting to use ALSA directly and whilst snap can support this, it’s better to use PulseAudio (which might also actually be Pipewire, to your snap, they’re one and the same).

So you need to configure the environment just a little to get the ALSA/Pulse wrapper going, which would be applicable to both Java but other platforms in the same position of only having ALSA support natively.