title: Exception: java.lang.NoClassDefFoundError: javax/activation/DataHandler
body: <p>I am creating a chat application in javafx and I am trying to use the javamail api to verify the user's email. The problem is that when I run the application it shows me the following message:
  java.lang.NoClassDefFoundError: javax/activation/DataHandler
  I am using java 17, javafx 17, netbeans ide 12.0.</p>
  <p>This is the code I have written:</p>
  <pre><code>package chat;
  
  import java.util.Properties;
  import javafx.application.Application;
  import javafx.fxml.FXMLLoader;
  import javafx.scene.Parent;
  import javafx.scene.Scene;
  import javafx.scene.image.Image;
  import javafx.stage.Stage;
  import javax.mail.Authenticator;
  import javax.mail.Message;
  import javax.mail.MessagingException;
  import javax.mail.PasswordAuthentication;
  import javax.mail.Session;
  import javax.mail.Transport;
  import javax.mail.internet.InternetAddress;
  import javax.mail.internet.MimeMessage;
  
  public class Chat extends Application{
     private Parent raiz;
     private Scene scene;
     private Stage stg1;
     private Image imagenx;
  
     @Override
     public void start(Stage stage) throws Exception {
        raiz = FXMLLoader.load(getClass().getResource(&quot;Chat.fxml&quot;));
        scene = new Scene(raiz);
        scene.setUserAgentStylesheet(getClass().getResource(&quot;chat.css&quot;).toExternalForm());
        stg1 = stage;
        stg1.setScene(scene);
        imagenx = new Image(getClass().getResource(&quot;icono.jpg&quot;).toString());
        stg1.getIcons().add(imagenx);
        stg1.setTitle(&quot;Video chat&quot;);
        stg1.setWidth(800);
        stg1.setHeight(600);
        stg1.show();
     }
  
     private void enviarMail(String destinatario){
        String remitente = &quot;mi remitente&quot;;
        String asunto = &quot;enviar correo de confirmacion&quot;;
        String cuerpo = &quot;mensaje a enviar&quot;;
        String clv = &quot;1234&quot;;
      
        Properties props = System.getProperties();
        props.put(&quot;mail.smtp.host&quot;, &quot;smtp.gmail.com&quot;);
        props.put(&quot;mail.smtp.user&quot;, remitente);
        props.put(&quot;mail.smtp.clave&quot;, clv);
        props.put(&quot;mail.smtp.auth&quot;, &quot;true&quot;);
        props.put(&quot;mail.smtp.starttls.enable&quot;, &quot;true&quot;);
        props.put(&quot;mail.smtp.port&quot;, &quot;587&quot;);
      
        Autenticador aut = new Autenticador(remitente,clv);
        sesion = Session.getInstance(props,aut);
        mm = new MimeMessage(sesion);
  
        try{
          mm.setFrom(new InternetAddress(remitente));
          mm.addRecipients(Message.RecipientType.TO, destinatario);
          mm.setSubject(asunto);
          mm.setText(cuerpo);
          try(Transport transport = sesion.getTransport(&quot;smtp&quot;)) {
              transport.connect(&quot;smtp.gmail.com&quot;, remitente, clv);
              try{
                  transport.sendMessage(mm, mm.getAllRecipients());
              }
              catch(MessagingException ex){
                  System.out.println(ex);
              }
          }
          catch(Exception ex){
              System.out.println(ex);
          }
        }
        catch(MessagingException ex){
          System.out.println(ex);
        }
     }
  
     public static void main(String[] args) {
        launch(args);
        enviarMail(&quot;example1@gmail.com&quot;);
     }
  }
  
  class Autenticador extends Authenticator{
     private String smtp_usuario = &quot;&quot;;
     private String smtp_pass = &quot;&quot;;
  
     Autenticador() {}
  
     Autenticador(String user , String pass) {
       this.smtp_usuario = user;
       this.smtp_pass = pass;
     }
  
     @Override
     public PasswordAuthentication getPasswordAuthentication() {
       return new PasswordAuthentication(this.smtp_usuario, 
       this.smtp_pass);
     }
  }
  </code></pre>
  <p>The error is generated in this line of code:
  mm = new MimeMessage(sesion);</p>
  <p>change the library from javax.mail to jakarta.mail, update netbeans to version 12.6, I have version java 17 installed, add the jar jakarta.activation, but when I run the project in netbeans this error is generated: java.lang.NoClassDefFoundError: jakarta/activation/DataHandler. Googling I found that I should add the following dependency:</p>
  <pre><code>&lt;dependency&gt;
    &lt;groupId&gt;jakarta.activation&lt;/groupId&gt;
    &lt;artifactId&gt;jakarta.activation-api&lt;/artifactId&gt;
    &lt;version&gt;2.0.1&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  <p>query, where should I add the pom.xml file with the dependency and how to use the jakarta.activation jar? I'm self-taught so maybe the question is very obvious.Apart from JavaMail is there any other library that I could use to send email?</p>