You can use Java Media Framework to produce sound but it is not necessary because you can work with javax.sound.sampled package and integrate it with Java Swing.
In python take a look at pyaudio library and also take a look at PythonInMusic it has a whole lot of collection of various A/V module.
Also, take a look at Beeper.
It is a GUI program, using only J2SE classes, that can produce a sound
of configurable tone & duration, and (with a bit of tweaking) at
different raw volumes
Thanks to @Andrew for once again correcting me.