Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaMail API from Maven

I am trying to upgrade to latest Java Mail utility.

From

<dependency>     <groupId>javax.mail</groupId>     <artifactId>mail</artifactId>     <version>1.4.7</version> </dependency> 

to (my Intention)

<dependency>     <groupId>javax.mail</groupId>     <artifactId>mail</artifactId>     <version>1.5.1</version> </dependency> 

But I don't find 1.5.1 for mail artifact,

but I can see

<dependency>     <groupId>com.sun.mail</groupId>     <artifactId>javax.mail</artifactId>     <version>1.5.1</version> </dependency> 

My Question is why group id changed and if I change the group id for 1.5.1 do I need to change all my mail implementation that is already present (package name change and any other stuff) and what is the difference between com.sun.mail vs javax.mail?

like image 481
Kumar Avatar asked Feb 25 '14 16:02

Kumar


People also ask

How to use javax mail maven?

How to use javax mail maven? For the implementation of Javax mail, we need to download from the official website of java otherwise we can add the maven dependency. Download the latest version of the JavaMail reference execution and recollect it for your undertaking gathering.

What is JavaMail API?

The JavaMail API provides a platform-independent and protocol-independent framework to build mail and messaging applications. The JavaMail API is available as an optional package for use with the Java SE platform and is also included in the Java EE platform.


1 Answers

The Maven coordinates changed some time ago to be compatible with the scheme described here. The new coordinates are here.

In short:

  • The groupId javax.mail is no longer used for the implementation.
  • There is a new artifact at javax.mail:javax.mail-api. It provides the javax.mail-api.jar file. This contains the JavaMail API definitions only, suitable for compiling against.
  • com.sun.mail:javax.mail contains the javax.mail.jar file, the JavaMail reference implementation jar file, including the SMTP, IMAP, and POP3 protocol providers.

So, you should either use com.sun.mail:javax.mail for compilation and packaging/deploy, or use javax.mail:javax.mail-api for compilation and then deploy the com.sun.mail:javax.mail jar where appropriate (e.g., your Tomcat lib).

like image 144
Bill Shannon Avatar answered Sep 20 '22 07:09

Bill Shannon