Well I am a pretty funny guy, and here are the main things that affect your humor:
1. Your style: My style is kind of observatory, in other words, I hear a story or look at a person and make a joke such as things as stupid as "wow this lecture is more boring than Al Gore on downers". I have friends that incorporate more faces and voices and physical movements in their jokes that will generate laughs.
2. Use names that are stereotypical, its hard to explain the situation, but in a situation where say you are making a joke about terrorists or iraqi people, use a name such as Akmed, or Muhommed(sp) or for a fat white guy use Phil or Tim, or for some stoner use Jeff, names that just sound funny in the right situation in the terms of a metaphorical joke, but my favorites are still Bill and Steve.
3. It depends on your audience, for example you dont make a sex joke in front of your parents or teachers, so you shouldnt make a corny joke on your friend, such as how small in penis is, when your in a group outside your main friends. Cause it will just seem awkward.
But all in all, comedy should just be fun and laid back, I just recommend hanging around your other guys that are funny, be calm cuase the best jokes come from being calm, laid back and being bold. The last bit of advice is, if you ever feel like you are in a situation where you have to be funny, chances are you will be trying to hard and none of your jokes will seem natural or all that funny in the first place.