Add java packaging and clean up a few build issues