 In 1775, he enlisted in the Spanish Navy and joined an expedition under the command of Alejandro O'Reilly which aimed to put an end to the incursions of the Barbary pirates in the Spanish Levante.Two years later he passed his examination and in 1778 obtained the authorization to perform surgery in Valencia.Due to the siege of Gibraltar, he joined the core of military surgeons as assistant second surgeon.