James had actually just been walking along, not paying too much attention, when he tripped over something. He picked it up and instantly recognized it as a lamp, so his first instinct was to see what the genie in this lamp was like, so he rubbed it.