Rewrite service script using java

Signed-off-by: walteryang <walteryang47@users.noreply.github.com>