Arkimedes edited answer sounds like a good solution to me. I would warn you though, looking into and using Java Native Interface (JNI) is not easy. It's nothing like pure Java, or so i have read.