adding snapshot in java code