sentence: he reached java in 1827 , but in 1829 he left the service , and gave himself largely to preaching , writing and distributing christian books , visiting the ships in the seaports of siam , singapore , macau , and other places .