|
| I am new to the websphere version of eclipse.
I started to implement a javamail feature in my project and encountered the following error in the eclipse editor at compile time.
unhandled exception type NoSuchProviderException
I had entered some Javamail sample code from the various examples.
Below is a portion of the code. The error actually occurred at the last line in this sample code.
String host = "something";
String username = "username";
String password = "password";
// Create empty properties
Properties props = new Properties();
// Get session
Session session = Session.getDefaultInstance(props, null);
// Get the store
Store store = session.getStore("pop3");
I searched the web looking for why I was getting this error and it seems there are lots of reasons for getting this error. Mostly this error occurs at run time when a required jar file is not found in the class path correctly.
These answers did not address the compile time error.
In the end I realized it was not a jar issue at all but a restriction of the Eclipse IDE. It was indicating I needed to add a try/catch block around this code. This is a good idea and I now realize what is required but it took time to realize this.
Thus I am submitting this post so that future developers who encounter this can hopefully search on "javamail unhandled exception type NoSuchProviderException"
and find this text to help them solve the problem more quickly.
The solution requires something like
try{
Store store = session.getStore("pop3");
...
}catch (Exception ex) {
System.out.println(ex.getMessage());
}
|
|