1. In a 4- to 5-quart pan over high heat, bring about 2 quarts water to a boil. Add green beans and cook until crisp-tender to bite, about 3 minutes. Drain.
2. In a lightly oiled 3-quart baking dish, arrange about a third of the ham, followed by a third of the beans and a third of the potatoes. Repeat to make two more layers.
3. In a bowl, beat eggs, milk, lemon juice, salt, and pepper just to blend. Pour over potatoes. Cover dish with foil.
4. Bake gratin in a 350° oven until potatoes are tender when pierced, about 45 minutes. Uncover, sprinkle cheese evenly over top, and continue to bake until cheese is browned and bubbling, about 25 minutes longer.