I'll be visiting Japan soon and I'll be meeting a friend there.
I was wondering if the etiquette there was to give a gift when you first arrive or when you'll be leaving.
When should I give the omiyage?
When you meet them.
You may well get "reverse omiyage" from your friend when you're leaving, though!
Definitely arrive with a gift from your home country. Edibles and tea or coffee are common gifts and widely appreciated.
You give it as soon as things have settled down and you're at their home. They WILL give you something back when you leave, and the value of their gift to you will depend on the value of the gift you give them. Thus, while it is important to not get something too cheap, it is likewise important to not overdo it either.