Solver in Java