Search code examples
jakarta-mailjavax.activation

Can't send email using javamail and jdk 12


I used to send emails with javamail and Java 8.

Now that I upgraded to Java 12 I get the java.lang.NoClassDefFoundError: javax/activation/DataHandler.

I added the javax.activation-api-1.2.0.jar and now I get java.lang.NoClassDefFoundError: com/sun/activation/registries/LogSupport.

This is because javax.activation-api-1.2.0.jar doesn't have the com.sun... package that previous versions had.

What jars should I put on my project to properly send and email with java 12? And where to find them?

There are a lot of confusing sources like:

https://repo1.maven.org/maven2/javax/activation/javax.activation-api/1.2.0/

https://eclipse-ee4j.github.io/jaf/

https://www.oracle.com/java/technologies/java-archive-downloads-java-plat-downloads.html#jaf-1.1.1-fcs-oth-JPR


Solution

  • You need the implementation jar file, not the API jar file. Use this.