I wanted to use javax.mail.session for a project to send a e-mail. When I try to use the Session class the error "The package javax.mail.session is not accesible". I use eclipse 2022-09 and jdk-18.0.2.1 which I downloaded from the Oracle site. The jdk is located in C:\Program Files\Java. I tried to add requires java.desktop; to my module-info.java file but it didn't worked. Also I tried to use jdk1.8.0_181 for my project but it also does not work.
If there is a better way to send a gmail in java 18 I'm open for solutions.
CodePudding user response:
looks like you miss the javax.mail-api
jar as a dependency in your project.
Add it and it should work.
If you are using maven, you can add
<!-- https://mvnrepository.com/artifact/javax.mail/javax.mail-api -->
<dependency>
<groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId>
<version>1.6.2</version>
</dependency>
to your pom.xml
BTW: javax.mail-api
has changed to jakarta.mail-api