java based solution