Hi Frances
Yes, that does look like John Harley sr in Rushen Gaol. The "army pensioner, age 60, born Scotland" fits exactly.
I found the whole family on the island, split up, presumably due to their straightened circumstances ( assuming that John sr was in gaol for non payment of debts, and not for another reason ) John jr was hard to find --Brian Lawson's reference numbers didn't find him, but I eventually tracked him down to Malew, district 1a, page 6.
John sr's wife, Mary Harley age 54, and daughter Margaret age 15, were also in Castletown (Malew district 3a, page 11). The other 2 daughters, Ann age 20 dressmaker and Jane age 15 milliner, were in Port St Mary (Rushen district 1, page 7) staying with a Jane Watterson age 15. Their census entry indicates that they were born on the IOM, but I'm pretty sure that these are the Harley sisters who were born in France and England. In 1849 Ann married Mark Watterson, baker, in Port St Mary (possibly related to the Jane Watterson who was living with Ann and Jane in 1841.)