Stolen from a Reddit thread cause the top answer isn’t super accurate (tldr Japanese “nipon” to Portuguese to Italian to English)
The first three Europeans that arrived in Japan in 1543 were Portuguese traders (António Mota, Francisco Zeimoto and António Peixoto). They were on a Chinese trading ship that had been blown off course and stopped on the island of Tanegashima to take on fresh water.
The Portuguese had three names for Japan. This is evidenced by the title of the 1603 Portuguese Japanese dictionary (Vocabvlario da Lingoa de Iapam) which uses Iapam and within in its pages also provides two other pronunciations for Japan being iippon and nifon. The reason for the multiple names appears to be due to:
The Portuguese first got the name Japan from the Chinese which called it Riben in Mandarin. Iippon is a relatively close translation of this word that sort of works for the Portuguese tongue. However, the Chinese language of wayfarers and the one that the first Portuguese to arrive in Japan would have heard would have been either Shanghainese or Hokkien (the dialect from Fujian). Shanghainese would have pronounced Nippon as Zeppen. Hokkien would have pronounced Nippon as Ji̍tpún. Nifon would have been relatively close to both. The Japanese that the Jesuits, who compiled the dictionary, would have likely to have spoken would have been influenced by the Japanese spoken in Nagasaki, which is where the Portuguese main base was. The accent of Nagasaki is what is called a Nikei-accent system, and widely used in south-west Kyushu. It has two contrasting tonal patterns, irrespective of the number of moras in the word. Thus Nippon would be Ni-Pon which then translates to Ia-pam
The Italians then started using the term Iapam. The largest Italian city of that era was Padua. Given the round about way the word Iapam got to Padua and based on the Italian spoken then, it got translated to Giapan. In an English travel book published in 1577 called “The History of trauayle in the VVest and East Indies …” the term Giapan was used.
Given that the Italian Gi sounds like J, it is not surprising that the English swapped Gi for J resulting in Japan.
Thus how Nippon became Japan appears tortuous starting with Portuguese being influenced by the type of Japanese spoken by the Jesuits in the 16th Century. Then from the three terms that the Portuguese used, the one that was perceived and recieved in Padua was Iapam, which was then translated into Italian as Giapan. And then how Giapan, used in the first known English travel journal that used the name, became anglicized into Japan.