Java Sound API - capturing microphone
This will get you the default one set by your OS.
AudioFormat format = new AudioFormat(8000.0f, 16, 1, true, true);
TargetDataLine microphone = AudioSystem.getTargetDataLine(format);
To select a particular input device (TargetDataLine) it is better to enumerate the mixers and filter the name of the Mixer you want.
Mixer.Info[] mixerInfos = AudioSystem.getMixerInfo();
for (Mixer.Info info: mixerInfos){
Mixer m = AudioSystem.getMixer(info);
Line.Info[] lineInfos = m.getSourceLineInfo();
for (Line.Info lineInfo:lineInfos){
System.out.println (info.getName()+"---"+lineInfo);
Line line = m.getLine(lineInfo);
System.out.println("\t-----"+line);
}
lineInfos = m.getTargetLineInfo();
for (Line.Info lineInfo:lineInfos){
System.out.println (m+"---"+lineInfo);
Line line = m.getLine(lineInfo);
System.out.println("\t-----"+line);
}
}