You can easily generate sampled sound data in Java and play it back without using native code. If you're talking MIDI things may get tricky, but I've not dabbled in that area.
To generate sampled sound data, you have to thing of the process backwards. We're going to act like the A-to-D and sample a continuous sound function over time. Your sound card does the same thing for audio through a mic or line in.
First, choose a sample rate (NOT the freq of the tone we're generating). Let's go with 44100 hz since that's likely the sound card playback rate (thus no sample rate conversion, that's not easy unless hardware does it).
// in hz, number of samples in one second
sampleRate = 44100
// this is the time BETWEEN Samples
samplePeriod = 1.0 / sampleRate
// 2ms
duration = 0.002;
durationInSamples = Math.ceil(duration * sampleRate);
time = 0;
for(int i = 0; i < durationInSamples; i++)
{
// sample a sine wave at 440 hertz at each time tick
// substitute a function that generates a sawtooth as a function of time / freq
// rawOutput[i] = function_of_time(other_relevant_info, time);
rawOutput[i] = Math.sin(2 * Math.PI * 440 * time);
time += samplePeriod;
}
// now you can playback the rawOutput
// streaming this may be trickier