Improved message error for java method