Rearrange source, add Java for embedding in, uh, Java.