Craving is a strong or almost irrisistible desire for something that you feel you must have (but often can't or shouldn't have).
Craving is often experienced as 'a bodily desire', a desire that seems to come from a bodily need, rather than from a thought, volition, emotion, or wish.
- 'She craved a cigarette but stifled the desire as she felt the professor would not approve'.
- 'During pregnancy I craved onions constantly and ate them all the time.'
It can relate to sexual desire, or be an addiction - again, the desire is experienced as a 'bodily need'.
Longing is more an emotional desire. The wish for something, or for somebody that is not there. Longing is much more 'a wish' than 'a bodily need'. It is also not necessarily connected to the need for action, and can be vague and unfocused. Whereas craving is more likely to be fulfilled by action.
- 'He longed to visit Istanbul again'
- 'She longed for the time when they were together'.
Yen relates more to 'preference' and also, 'habit'. It describes a natural leaning, bent, or talent towards something, or a preference for something, which is often 'regular or done repeatedly'.
It also means 'being good at something'. It means you are 'In your groove' - doing something you have a natural talent for as in:
'You really have a yen for sports!' - which means, 'you have a natural talent, leaning, or bent, for sports'.
'She had a yen for polo mints and sucked on them constantly' (preference)
'You have a yen for coming top of the class, don't you?' (natural talent, bent, leaning)
It may help to translate 'yen' as meaning 'having a liking for', I think that defines it rather well.
Yen - Definition
'a strong desire for something' it says here (though my own knowledge of the word is more 'desire' than "strong desire'. Ah dictionaries, these days 🙄