Hamilton's father served in the Irish army under his brother-in-law James Butler, Earl of Ormond, in the
Irish Confederate Wars (1641–1648) and the
Cromwellian conquest of Ireland (1649–1653). It has long been believed that James, aged about 16 or 17, his mother and siblings lived in
Roscrea, County Tipperary, and were spared when on 17 September 1646, the Confederate Ulster army under
Owen O'Neill captured Roscrea Castle from the Munster confederates and killed everybody else in the castle. It seems that this Lady Hamilton was not James's mother but his aunt, the wife of Sir George Hamilton of Greenlaw and Roscrea, while James, his mother, and siblings were safe in
Nenagh, west of Roscrea. This confusion was already made by Carte (1737) and repeated by later authors. On 28 July 1647 Ormond abandoned Dublin to the parliamentarians and left Ireland. In 1648 Phelim McTuoll O'Neill stormed Nenagh taking it for Owen Roe O'Neill and Rinuccini, but it was still in the same year recaptured by
Inchiquin, who was now allied with the royalists. In 1650, Hamilton's father was governor of
Nenagh Castle when the Parliamentarian army under
Henry Ireton captured the castle on the way back from the unsuccessful
siege of Limerick to their winter quarters at
Kilkenny. Early in 1651, when Hamilton was about 21, his family followed Ormond into French exile. They first went to
Caen where they were accommodated for some time by
Elizabeth Preston, the Marchioness of Ormond. He seems then to have been employed at
Charles II's wandering exile court in some ways, whereas his mother went to Paris, where she lived in the convent of the , together with her sister Eleanor Butler, Lady Muskerry. Hamilton seems to have been the "Sir James Hamilton" who together with William Armorer, brother of
Nicholas Armorer, executed the traitor Henry Manning near Cologne in December 1655. In the late 1650s before the
Battle of the Dunes (1658), Hamilton was lieutenant-colonel of
Middleton's Scottish regiment of foot, which was part of James II's
Royalist Army in Exile, but he seems to have lost his post to
William Urry when
Newburgh became colonel. == Restoration ==