About JavaMail;

Please have a look in the snippet of this code

I am just trying to get a number of messages in a folder.


import javax.mail.*;
import java.io.*;
import java.net.*;
import java.util.*;

class first{
      public static void main(String[] args) throws MessagingException{
                  URLName urln = new URLName("164.164.61.24");
                  Properties pros = System.getProperties();
                  Session session = Session.getDefaultInstance(pros, null);
                  Store store = session.getStore();
                  store.connect();
                  Folder f = store.getDefaultFolder();
                  System.out.println("The count is " + f.getMessageCount());
      }
}

It is compiling perfectly but when it comes to runtime it is giving me this error

C:\jdk1.2\bin\java.exe   first
Working Directory - C:\javamail\testing\
Class Path - c:\jdk1.2\lib\;c:\jsdk2.1\servlet.jar;c:\jsdk2.1\server.jar;c:\javamail\javamail-1.1.2\mail.jar;.;C:\kawa321\kawaclasses.zip;c:\jdk1.2\lib\tools.jar;c:\jdk1.2\jre\lib\rt.jar
javax.mail.NoSuchProviderException: Invalid protocol: null
      at javax.mail.Session.getProvider(Session.java:208)
      at javax.mail.Session.getStore(Session.java:306)
      at javax.mail.Session.getStore(Session.java:286)
      at javax.mail.Session.getStore(Session.java:272)
      at first.main(first.java:11)
Exception in thread "main" Process Exit...

Pleaes help me to solve this error
seenuvAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

laurentjCommented:
try with
URLName urln = new URLName("pop3://user:password@164.164.61.24:110");  
and
Store store = session.getStore(urln);

Laurent.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.