Mittwoch, 18. April 2007

Silent Refusal to J2SE by Google Calendar API

If we download the Google Calendar API for java and try to compile any sample program provided by it, or just write a piece of code with the help of tutorial offered by GoogleCode, some of us may encounter the following exception:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/MessagingException

Actually if we try to look up in javax package, we may not find the mail class. What is the problem?
The answer is not so difficult but still seemed me a little weird: one must add the mail.jar lib file of J2EE as package file so that the main problem could be compiled correctly and run. In fact javax.mail.MessageException lies in J2EE but not J2SE lib, but the JavaVM or any IDE can't gives more information about it. So i refer to it as a "silent refusal to J2SE", which quite possibly may be omitted by J2EE developers.

Tipp: If you use J2SE and want to develop using Google Data API, look the needed things in J2EE up, es lohnt sich auf jeden Fall.