Make Java examples compatible to new listener approach