switch to non-deprecated JavaWriter methods

Ever since #295 ,we've been generating a lot of warnings for using deprecated JavaWriter methods.