How to write a automation code in Java ?