Java not working properly on chat avenue