The C major 9 chord, Cmaj7(9) respectively Cmaj9, is a C major chord with a major 7th B and an additional major 9th (9) D. To get the 9th on the guitar, just take a root C on one of the higher strings and slide up 2 frets (a whole-step) to D. However, it will be written as 9 and not as 2, because it is a chord extension (the number 2 only occurs in sus2 chords).
A C maj7(9) respectively Cmaj9 has the notes C (1), E (3), G (5), B (maj7) and D (9). You can omit the 5th if you want.
If you don't play the root C, the remaining tones form a Em7 chord. This phenomenon is called „3rd relationship”.
Especially in jazz and latin music maj9 chords are very common. Major 9th chords can normally be played instead of a basic major 7th chord. It sounds even great and interesting, when you move them around freely, like for example Fmaj9 Ebmaj9 Dbmaj9 Cmaj9 or like Ebmaj9 Dbmaj9 Fmaj9 Ebmaj9 Dmaj9. Just try around.