Peer to Peer Chat Security Options?
===

Ok, so for fun I am coding a messenger program in Java. Fun right? :)

I wanted to create a messenger that worked between two PC's tha didn't have to consult anyone else and you just input the IP you wish to chat with. Later I would implement a user name system where you contact the server to find out their IP.

I got the AES and RSA working perfecly and then I realized that a man in the middle attack is possible when you do the public private key exchange. This kinda makes me angry...

Is there any solution to a man in the middle attack other than using a CA or having a server exchange user names and/or public private key info?

Is there any programs already made like this that I can look to?

Thanks guys!

**Please note: Goal is to have secure peer to peer communication without a server. Also no vulnerabilities like man in the middle.**