Jumping up on people is a natural form of greeting for a dog. When dogs approach each other, they sniff faces and ears and might even submissively lick at the mouth. Since people walk upright, dogs must jump up in order to say hello.
To knee a dog in the chest, yell, hit, or otherwise punish the dog for jumping up is rude. Doing so could actually teach the dog that being friendly leads to discomfort and people are to be avoided. Kneeing a dog can also injure the dog if done with enough force.
The best way to prevent your dog from jumping up is to teach him how to greet people appropriately. A wonderful alternate behavior to jumping is sitting. When you come home or wake in the morning, only pet your dog after he sits. Cue him once to sit. If he does, praise, hug, kiss, etc. to your heart’s content. However, if he does not sit, shrug and walk away. Should he continue to jump, ignore him for about 30 seconds then ask him again to sit. Pet him if he does but walk away again if he doesn’t.
If he still has not responded, you have two options. First, ignore him until he at least has all four paws on the floor for about 5 seconds, then softly praise him and give him a little pat on the head (hugs, kisses, and the sort are too much reinforcement for his lackluster performance and may get him excited all over again). Second, go into another room and close the door, separating yourself from your dog. This should make the message pretty clear – your dog has no access to you when he jumps. Leave the room after 1 minute and tell him to sit. Repeat the above until you are (finally!) able to say hello.
You are not the only one who must not pet your dog when he jumps up. No one should pet him, smile at him, coo to him, or otherwise reinforce this behavior. When you are on walks, tell him to sit as people approach you. Having him sit before he starts jumping will keep the situation under control. Allow people to pet him as long as he refrains from jumping. If he jumps, say “too bad!” and walk away. He will learn that jumping causes good stuff to end while sitting or standing keeps the petting and treats coming.
There are a couple techniques (in addition to having your dog sit) that you may use if your dog tends to jump on you in situations other than greeting:
Dodge out of your dog’s path. When your dog starts to jump, say “off” and swiftly step to the side or backwards. Praise when all four paws are on the floor.
Hip check. As your dog jumps, say “off” while you turn sideways and thrust your hip toward him (dogs use a similar maneuver with each other to show who is in control). This should throw him slightly off balance. Praise when all four feet are on the floor.