I have pulled out quite a few hairs trying to get my java VM to recognize the settings in the javamail.providers file. The javamail API is extensible. Meaning you can write your own mail protocol implementation if you want. Well I didn't write my own but I am experimenting with the maildir implementation by infodancer.
I created a new file named javamail.providers in the lib directory in $JAVA_HOME and placed the following entry in it.
protocol=maildir; type=store; class=org.infodancer.mail.maildir.DirectoryStore; vendor=infodancer
The JVM seemed to regard my efforts with disdain and totally ignored this file. When I run my test class (which contains the following code)
Session session = Session.getDefaultInstance(System.getProperties());
Store store = session.getStore(new URLName("maildir:///home/vpopmail/domains/localhost/postmaster/Maildir/"));
Folder f = store.getDefaultFolder();
I get a nasty old exception (javax.mail.NoSuchProviderException: No provider for maildir to be precise)
Then it occured to me that I may be putting the providers file in the wrong place. I am still using the same javamail library I downloaded four years ago (that's how long i have been working with mail), the documentation may have been updated with out my knowing it. So I tried putting the javamail.providers file in $JAVA_HOME/jre/lib and suprise, suprise it works!!