"just in time" is a common phrase that indicates an event occurred before the necessary deadline, but with a very small margin. The phrase is referring specifically to the event that was almost missed. The "just" refers to the small margin, since "in time" simply means occurred before the deadline.
I arrived just in time to catch the train (almost missed it!)
We managed to buy a Christmas tree in time for the holidays (with a week to spare)
"on time", however, refers less strongly to a specific deadline. It means something very similar, but you might use it more where you were just referring to an event that happened within the required period of time. It also has more of disconnected feeling and doesn't have to be specifically pointing to a deadline.
"I woke up on time"
implies perfectly "I woke up when I had planned to", whereas
Person 1: "I woke up in time ..."
feels like it needs a something else clarifying what it refers to, and would likely prompt the question
Person 2: "In time for what?"
It's much less usual to put "just" in front of "on time" to emphasise a near miss. Maybe this is because "on time" doesn't explicitly state its deadline? I'm not sure. I do know it sounds weird though. If you need to emphasise a near miss, it's safer to use "just in time" instead.
"I got to my class just on time" is much less common in English, and depending on the intonation it could sound wrong, like you had meant to say "just in time". A bit of extra emphasis on the 'just' would make it sound more natural.
There are some other more usual instances where you might hear the world "just" in front of "on time". One that jumps to mind is
I submitted my essay only just on time
Here the "only" adds that needed emphasis to the "just". You could also rearrange it to give a slightly more natural sentence structure, such as:
I only just submitted my essay on time
Honestly the differences are subtle, and a lot of the time mostly interchangeable. Like a lot of English, it's pretty arbitrary, and the only sure-fire way to get it right is spend a lot of time talking and listening with native speakers, and eventually you get an innate grasp of what sounds right and what doesn't. Here I am trying to explain it and I feel like I'm always on the verge of contradicting myself. Ha. Anyway, hope this helps.