James Cotter attached himself to the Royalist cause in the Civil Wars, and family tradition has him fighting for Charles II at the Battle of Worcester in 1651. Cotter was probably part of King Charles' military entourage when in exile and on his restoration to the throne in 1660 was a lieutenant in a foot (infantry) regiment. Exempted from the general pardon of persons who had taken arms against the monarchy in the recent wars were the "regicides" – those who had been instrumental in the trial and execution of Charles I. A number of the regicides fled the country to escape trial and were declared traitors and outlaws. James Cotter founded his career in royal service by organising and carrying out the assassination of one of the regicides, John Lisle, in Switzerland (at Lausanne, 14 September 1664). Another regicide, Edmund Ludlow, was also targeted but escaped assassination. The Dictionary of National Biography, amongst other sources, states that Cotter carried out the killing under the pseudonym Thomas Macdonnell. However, in his biographical essay Ó Cuív dismisses this, stating that Cotter and his accomplices, Miles Crowley and John Rierdan (both Irish gentlemen fallen on hard times), were quite open about the incident. They were, indeed, carrying out a royal and judicial warrant and were acting entirely within English law. They were all rewarded by the English crown on their return and their rewards were officially recorded. Crowley fired the shot that killed Lisle, he was attacked in a churchyard, whilst Cotter and Rierdan fought off Lisle's guards.
Following this incident Cotter was made a captain, and in 1666 went to the West Indies commanding a company in a new-raised regiment of foot. In 1667 he commanded 700 men in an attack on the island of St Christopher when he was captured by the French. In 1680 he was promoted to colonel and appointed Deputy-Governor of the island of Montserrat; in 1681 he was made the island's Governor. With a royal pension and the profits from his West Indian governorship James Cotter became very wealthy and bought out the interests of most of his immediate family in his father's former lands, and considerably extended his holdings by new purchases in the Cork area.
It is likely that James Cotter was an intimate of James II and may have served at sea with the king when the king was Duke of York, and an admiral, in the war against the Dutch of 1665. King James is reported to have familiarly referred to Cotter as "Shaymus Bwee," Séamus Buidhe in Irish. In June 1685 Cotter is recorded as a Lt. Colonel serving in Sir William Clifton's Regiment of Foot. James Cotter is believed to have been knighted by King James in 1685 following the Battle of Sedgemoor. The earliest official reference to Cotter as a knight occurs in 1686, which supports this timing; the records of the occasion of the dubbing are no longer extant.
James II had converted to Roman Catholicism before he succeeded to the throne, the birth to him of a son and heir who would be raised a Catholic precipitated the Glorious Revolution of 1688, and James fled England; where his Protestant daughter Mary, and son-in-law William III, came to power. In order to retrieve his fortunes King James landed in Ireland in March 1689 with French troops. At this time Sir James Cotter, a Catholic like his king, was made commander of the Jacobite forces in Cork, and he was also returned as the first member of the Irish Parliament for the city of Cork. Cotter is said to have entertained King James at his house in Anngrove in 1689 and was reputedly promised an elevation to the peerage as a marquis. Cotter commanded "Clare's Dragoons," described as one of the finest of the Jacobite cavalry regiments, and was involved in a skirmish at Lisnaskea, where his force was ambushed. On 11 February 1690 Cotter was appointed Governor of the City of Cork, and in April was empowered to collect taxes from the whole of County Cork. Following King James' defeat at the Battle of the Boyne, at the start of the campaign of 1691, Sir James Cotter was made Brigadier General in command of all the Jacobite forces in counties Cork, Kerry, Limerick and Tipperary. Cotter won two clashes with the Williamite forces but was ultimately defeated in the Battle of Bottlehill, at Ballymagooly near Mallow, on 29 April 1691. During the time of his military and civil authority Sir James Cotter treated the Protestant landowners well, not allowing his troops to despoil their property or for acts of reprisal to occur. He was rewarded for his moderation when, following the surrender of the Jacobite forces under the Treaty of Limerick, the support of his Protestant neighbours allowed him to retain his property and lands in full, despite legal attempts to force his forfeiture.
In the last years of his life he was regarded as the natural leader of the Catholic community of Cork; he devoted time and resources to patronising Irish literature and protecting Roman Catholic clergy, including John Sleyne Bishop of Cork and Cloyne, from the authorities. Following his death in 1705 he was buried in his family's burial vault at Carrigtwohill, a vault he had built to hold his father's remains.
Sir James Cotter was, in the style of previous generations of Irish chieftains, a great patron of poetry and other writings in the Irish language, with many poems about, or dedicated to, the Cotters by poets such as Dáibhí Ó Bruadair, Uilliam Mac Cairteáin, Uilliam Ruadh Mac Coitir (a fellow Cotter), Seán Clárach Mac Domhnaill and Éamonn do Vál surviving. Domhnall Ó Colmáin included much biographical material concerning Sir James Cotter in his tract Párliament na mBan.
Sir James Cotter married twice. His first marriage, to Mary daughter of Sir William Stapleton, was without issue; his second wife was Ellen Plunkett daughter of Matthew, 7th Lord Louth. His eldest son, James, inherited his wealth and patronage of the Catholic population of Cork, but not his moderation or astute political instinct and ended his life on the gallows. His other children were: Laurence, Mary, Alice and Monica. He is the patrilinear ancestor of the Cotter baronets of Rockforest in County Cork.