If I understand you correctly, you will need to rely on native code (eg JNI) - how you do so with native code is OS dependent.