Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
NoClassDefFoundError:javax/mail/Session_Java_Jakarta Ee_Jakarta Mail - Fatal编程技术网

NoClassDefFoundError:javax/mail/Session

NoClassDefFoundError:javax/mail/Session,java,jakarta-ee,jakarta-mail,Java,Jakarta Ee,Jakarta Mail,我正试图发送一封电子邮件,其中包含表格中的数据。目前正在尝试使用Gmail,目标是从本地服务器发送。但这给了我一个例外。我已经在lib中添加了.jar。对不起,如果这个问题很愚蠢,我是新手 如何一步一步地修复它 public void sendMail(字符串发件人、字符串密码、字符串收件人、FormModel FormModel){ 属性=新属性(); properties.put(“mail.smtp.auth”、“true”); properties.put(“mail.smtp.sta

我正试图发送一封电子邮件,其中包含表格中的数据。目前正在尝试使用Gmail,目标是从本地服务器发送。但这给了我一个例外。我已经在lib中添加了
.jar
。对不起,如果这个问题很愚蠢,我是新手

如何一步一步地修复它


public void sendMail(字符串发件人、字符串密码、字符串收件人、FormModel FormModel){
属性=新属性();
properties.put(“mail.smtp.auth”、“true”);
properties.put(“mail.smtp.starttls”,“true”);
properties.put(“mail.smtp.host”、“smtp.gmail.com”);
properties.put(“mail.smtp.port”,“587”);
Session Session=Session.getInstance(属性,新验证器(){
@凌驾
受保护的密码身份验证getPasswordAuthentication(){
返回新的PasswordAuthentication(from,pass);
}
});
Message Message=pmessage(会话、发件人、收件人);
试一试{
传输。发送(消息);
}捕获(消息异常e){
e、 printStackTrace();
}
}
私人消息pmessage(会话会话、字符串myaccount、字符串收件人){
Message Message=新的mimessage(会话);
试一试{
message.setFrom(新Internet地址(myaccount));
message.setRecipient(message.RecipientType.TO,新Internet地址(收件人));
消息。设置主体(“公式”);
message.setText(“测试”);
返回消息;
}捕获(地址e){
e、 printStackTrace();
}捕获(消息异常e){
e、 printStackTrace();
}
返回null;
}
解放党
预期的输出是通过邮件发送的。

请尝试以下操作之一。之前曾为我处理过类似问题:

  • 将activation.jar与mail.jar一起添加到类路径中。 [

  • 从工具栏中单击“文件”
  • 项目结构
  • 选择左侧面板上的模块
  • “依赖项”选项卡选择“+”→ jar或目录

尝试以下方法之一。之前曾为我处理过类似问题:

  • 将activation.jar与mail.jar一起添加到类路径中。 [

  • 从工具栏中单击“文件”
  • 项目结构
  • 选择左侧面板上的模块
  • “依赖项”选项卡选择“+”→ jar或目录

1)粘贴异常2)您添加了什么jar 3)如果是正确的jar,它可能不在类路径上。@Antoniossss thx我做了一些更改,所以它不在类路径上。如何更改取决于您运行应用程序的方式。@Antoniossss我使用intellij idea 2019,我使用(Shift+F10)运行1) 粘贴异常2)您添加了什么jar 3)如果是正确的jar,它可能不在类路径上。@Antoniossss thx我做了一些更改,所以它不在类路径上。如何更改取决于您运行应用程序的方式。@Antoniossss我使用intellij idea 2019,我使用(Shift+F10)运行