Java 如何将mail.jar添加到oracle sql developer以解决此错误

Java 如何将mail.jar添加到oracle sql developer以解决此错误,java,jakarta-mail,Java,Jakarta Mail,我已经看了很多关于的帖子(我需要将mail.jar和activation.jar添加到oracle Sql developer中): 我已经用java编写了OracleForms6i使用的其他类,但无法使此电子邮件部分正常工作。似乎失败的代码是: import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.PasswordAuthentication; import javax.mail.S

我已经看了很多关于的帖子(我需要将
mail.jar
activation.jar
添加到oracle Sql developer中):

我已经用java编写了Oracle
Forms6i
使用的其他类,但无法使此电子邮件部分正常工作。似乎失败的代码是:

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 EnvoyerEmail {

    private String username = "xxxxxxx@gmail.com";
    private String password = "****";

    public void envoyer() {
        Properties props = new Properties();
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.starttls.enable", "true");
        props.put("mail.smtp.host", "smtp.gmail.com");
        props.put("mail.smtp.port", "587");
        Session session = Session.getInstance(props,
                new javax.mail.Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(username, password);
            }
        });
        try {
            Message message = new MimeMessage(session);
            message.setFrom(new InternetAddress("xxxxx@gmail.com"));
            message.setRecipients(Message.RecipientType.TO,
                    InternetAddress.parse("yyyyyy@gmail.com"));
            message.setSubject("Test email");
            message.setText("Bonjour, ce message est un test ...");
            Transport.send(message);
            System.out.println("Message_envoye");
        } catch (MessagingException e) {
            throw new RuntimeException(e);
        }
    }

    public static void main(String[] args) {
        EnvoyerEmail test = new EnvoyerEmail();
        test.envoyer();
    }
}
但是当它试图发送时,我一直收到上面提到的错误。我向您保证,类路径中有mail.jar、activation.jar、pop3.jar、mailapi.jar、smtp.jar、imap.jar。所以这不是问题所在。
我在甲骨文论坛上被建议,这将需要签署。我对这一点非常无知(我的java经验是使用JSP),但我认为我得到了
“安全/签名”
,但我仍然遇到同样的问题。

你到底在做什么,你需要向Oracle SQL Developer添加一个JAR?我需要在SQL Developer中执行java代码。我加载java文件夹(SQLDeveloper)中编译的java代码,我将创建一个过程,并使用EXEC.nameofprocdr执行它;您的意思是,您需要创建存储的Java过程,以便在运行Oracle数据库的JVM中执行Java?类路径中的jar文件太多了。如果您使用的是JDK 8或更早版本,则只需要mail.jar。如果您使用的是较新的JDK,那么还需要activation.jar。谢谢大家,但我不知道如何向sql developer添加mail.jar或activation.jar来执行我的java类
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 EnvoyerEmail {

    private String username = "xxxxxxx@gmail.com";
    private String password = "****";

    public void envoyer() {
        Properties props = new Properties();
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.starttls.enable", "true");
        props.put("mail.smtp.host", "smtp.gmail.com");
        props.put("mail.smtp.port", "587");
        Session session = Session.getInstance(props,
                new javax.mail.Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(username, password);
            }
        });
        try {
            Message message = new MimeMessage(session);
            message.setFrom(new InternetAddress("xxxxx@gmail.com"));
            message.setRecipients(Message.RecipientType.TO,
                    InternetAddress.parse("yyyyyy@gmail.com"));
            message.setSubject("Test email");
            message.setText("Bonjour, ce message est un test ...");
            Transport.send(message);
            System.out.println("Message_envoye");
        } catch (MessagingException e) {
            throw new RuntimeException(e);
        }
    }

    public static void main(String[] args) {
        EnvoyerEmail test = new EnvoyerEmail();
        test.envoyer();
    }
}