Updated java code, fixed regex, and added apidemos test