Receiving email using JavaMail is possible for both POP3 and IMAP. Here's an example:
Properties props = System.getProperties();
session = Session.getInstance(props, null); // get a mail session
store = session.getStore("imap"); // get relevent store type, in this case IMAP
store.connect(mailserver, username, password); // connect to mail server
defaultFolder = store.getDefaultFolder(); // get default or root folder
inboxFolder = defaultFolder.getFolder("INBOX"); // find and get INBOX folder
inboxFolder.open(Folder.READ_ONLY); // open the folder
Message[] inboxMessages = inboxFolder.getMessages(); // get all the messages
Change the store type to "pop3" in Session.getStore() for POP3 access.
Oh, btw, GMail supports both POP and IMAP - it depends on whether the user has enabled those kinds of access. If you login to your GMail account, look under 'Settings' and 'Forwarding and POP/IMAP' tab.