When I was creating a process to send an email using JavaMail in a Java batch, a ClassNotFoundException occurred, so I will summarize the cause and solution at that time.
The cause was simple and I made a mistake in loading the library. Originally, I wrote the following in Gradle's dependencies and loaded the library.
compile group: 'javax.mail', name: 'javax.mail-api', version: '1.6.2'
Now, the only libraries that fall are: javax.mail-api-1.6.2.jar
The only classes included in this library are those related to "javax.mail ~", and I get angry because I don't have enough classes when sending mail ... (although nothing is written in dependecy of maven repository)
Change the JavaMail library to load as follows.
compile group: 'com.sun.mail', name: 'javax.mail', version: '1.6.2'
The following two libraries will be dropped by this. javax.mail-1.6.2.jar activation-1.1.jar
The classes included in this "javax.mail" library are "javax.mail ~" related classes and "com.sun.mail ~" related classes. Using this library cleaned up the errors related to ClassNotFoundException.
Libraries related to java mail are quite confused by the similar group structure. The name of the package seems to work quite well, and it's very difficult to understand ...