Hacking was born into a Muslim family in the Ottoman Empire and was known as "Mistraslı Hasan". He was captured at the age of about 10–12 by the Venetians during the Morean War (1684–1699). After this he travelled to Perast in the Bay of Kotor, Adriatic Sea. Hacking was taken under the patronage of the local Zmajević and Martinović noble families and was baptised into the Catholic faith. He later studied in Rome and the University of Padua, also writing poetry in the Serbo-Croatian language, such as poem "Spjevanje događaja boja peraškoga" about the Battle of Perast (successful defense of Perast from the Ottomans in 1654).