Scrapped the java stub, going to do it in c instead. I hope that I do not regret this :P