Play Gmaj9 one string at a time and you hear G, B, D, F# and A. G is the root, B the major third, D the fifth, F# the major seventh and A the ninth. Said aloud, its notes are G, B, D, F sharp and A.
String by string, low to high, it plays G, D, A, B and F#. It runs from G on string 6 up to F# on string 1.
The open strings add notes to Gmaj9 too. String 4 gives D and string 2 gives B. String 5 stays silent. Your hand covers two frets, from 2 to 3. This page has three positions. The others start at frets 3 and 9.
Gmaj7 is very close. You only move strings 5 and 3. Inside Gmaj9 sits a complete D chord, made of D, F# and A. Moving to G, you keep one finger down.
You will find Gmaj9 in four different keys. In G major it is the Imaj9, in D major the IVmaj9 and in B minor the VImaj9. The rest appear in the key list.