Refactor the java code...

Signed-off-by: pyramid-X <rdxperiaz@gmail.com>