Playing pure sinusoidal tones
In a sense, your math is wrong.  In


double angle = i / (SAMPLING_FREQUENCY_IN_HZ / hz) * 2 * Math.PI;



… both of the divisions are done using integer arithmetic.  As a result, I get nothing more than a clicking noise.  To get the intended signal, you have to cast i to a double.  Better yet, write it instead as

double angle = 2 * Math.PI * i * hz / SAMPLING_FREQUENCY_IN_HZ;




By the Nyquist criterion, a sample rate of 8000 Hz means that you can play a frequency no higher than 4000 Hz.  Therefore, for robustness, you should do one of three things:


Throw an exception if hz &gt;= SAMPLING_FREQUENCY_IN_HZ / 2.
Let the sampling frequency vary, by setting it to 16 * hz, for example.
Set SAMPLING_FREQUENCY_IN_HZ high enough so that it covers the range of human hearing (44.1 kHz for CD audio, 48 kHz for DVD video soundtracks).


It would also be wise to define the fade-in / fade-out period as a multiple of the sampling rate.