Just’ and ‘only’ are adverbs that point to or emphasis one part of the clause.
In many cases you’ll come across in spoken English, ‘just’ is used as a softener. I’d better give you an example to explain what I mean by ‘softener’:
Can I just ask you a question? - what I’m saying here is ‘I want to ask you a question but I don’t want to inconvenience you and it’ll only take a short time’, whereas directly saying ‘Can I ask you a question?’ doesn’t have this tone.
So, we often use ‘just’ to add a polite tone, the word doesn’t specifically carry much meaning in itself.
There are other situations when we use ‘just’ but we can’t use ‘only’ in its place, for example, if I say ‘he was just here’, I’m trying to tell you he was here a few minutes ago.
So although I’ve told you about some differences, there are lots of times when they are synonymous. Basically, anytime you can use ‘only’, you can usually use ‘just’ to mean the same thing. But you’ve got to remember that the range of uses and meanings for ‘just’ are quite wide.