In non-Slavic loanwords ending in -ia, -i- has a double role: it palatalises the consonant, as it usually does, but it's also pronounced as -j-. For that reason, genitive, dative, locative singular and genitive plural of those words end in -ii: first -i- palatalises the consonant and is pronounced as -j-, second -i is a vowel.
Before 1936 or so, those words were written with -j-, so Julja, Julji. In fact, I think it was a better and more phonetic way to spell those words.
Note that in words of Slavic origin ending with -ia, that -i- isn't pronounced as -j- and disappears, so the genitive doesn't end with -ii, but -i.
-cia, -sia, -zia, -dzia – Slavic origin, genitive in -i
-nia – mixed; for a minimal pair: Dania /dańja/ Denmark, dania /dańa/ meals
-bia, -mia – usually non-Slavic, but there are few Slavic words ending that way, most importantly ziemia
-pia – not sure, most likely all non-Slavic
-fia, -tia, -dia, -ria, -lia, -chia, -hia, -kia, -gia – all non-Slavic, genitive in -ii
Note that for some of those consonants, like -t-, -d-, -r-, palatalisation has almost no phonetic effect.
I feel like the distinction between „-ja” and „-'a” is disappearing from some speakers, or at least it disappeared in my speech. I don't think I pronounce "Dania" and "dania" differently, nor I hear any characteristic that would tell me that the genitive of „dynia” is „dyni” and not „dynii”. The only pair I can hear the difference is "cj/sj" vs "ci/si" (which is still recognized in the orthography, unlike the other in nominative).