It comes down to how the names were changed when translated to latin, from two different sources.
First: the hebrew name, which also was the same in the arameic spoken when Jesus lived is יהשע (Jehoshoua'), and is the one we find in the hebrew bible.
The name of Jesus in the New testament (which is written in Greek), is Ιησους (Iesous). This is how the hebrew name was transcribed to greek, as we can see in the traditional greek translation of the hebrew bible, The Septuagint (short: LXX). Here we find the name Joshua (as in the successor of Moses) translated/transcribed exactly the same.
So why do we then use different names on the two figures? It all comes down to the most used bible translation used in the western church: The Vulgate. This translation was a translation to latin which based its parts of the Old testament on the hebrew text instead of the LXX, which quickly had been adopted as the "christian" old testament version.
Therefore, the vulgate translated the name of Jesus from greek, and the name of Joshua from hebrew, and got different results: Josue for the hebrew name, and Jesus for the greek name.
English, and most other languages in western Europe took the names from latin and thus kept the difference between them as well.
*edits for spelling errors