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