The example below shows a lookup of a JavaMail resource. The actual lookup name is determined by the application's deployment descriptors.
// Get the initial context as shown above ... Session session = (Session) initialContext.lookup("java:comp/env/mail/MailSession");
Related tasks
Developing applications that use JNDI