7 Replies Latest reply: Oct 27, 2011 4:32 PM by Bill Shannon-Oracle RSS

    javamail program runs from Netbeans, but crashes from jar file


      I have been struggling with this for some time now. I have a working program based on smtpsend.java, as described in the javamail faq. When I run this from Netbeans, the program runs fine. However, when I try to run the program by double-clicking the jar file in the dist folder, the program crashes just before the Session.getInstance(props, null) line as shown below:

      ResourceBundle labels = ResourceBundle.getBundle("resources.EmailProperties", Locale.ENGLISH);

      String subjectprefix = course + labels.getString("subjectprefix");
      String mailer = labels.getString("mailer");
      String mailhost = labels.getString("mailhost");
      String from = labels.getString("from");
      String replyto = labels.getString("replyto");
      String user = labels.getString("user");
      String password = labels.getString("password");
      String protocol = labels.getString("protocol");
      String success = labels.getString("success");
      String bodystart = labels.getString("bodystart");
      String bodyend = labels.getString("bodyend");
      String signature = labels.getString("signature");

      String file = f.getName();
      String to = StringUtils.getAddress(file);
      String subject = subjectprefix + file;
      String text = bodystart + file + bodyend + signature;

      try {

      Properties props = System.getProperties();
      props.put("mail." + protocol + ".host", mailhost);
      props.put("mail." + protocol + ".auth", "true");

      JOptionPane.showMessageDialog(null, "Next line causes crash from jar file on Windows 7 64-bit, JDK1.6.0_27");

      Session session = Session.getInstance(props, null);

      I am using javamail 1.4.4 with JDK1.5.0_u27 (64-bit) on Windows 7 64-bit.

      Is there a reason why the same program will run from within Netbeans (6.5.1), but crash when invoked from the jar file?