Note that there are some explanatory texts on larger screens.

plurals
  1. POJava Jar file not sending email when ran from a batch file?
    primarykey
    data
    text
    <p>All,</p> <p>The following code works fine and sends email when ran from within eclipse. However when i export from eclipse as a jar file and run the following command from a batch file it gives me error. Note: there are other files in the jar file that work fine when ran from the batch file.</p> <pre><code>java -cp C:\Users\Administrator\Email.jar LotusNotes.SendEmail </code></pre> <p>Exception:</p> <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/MessagingE xception at LotusNotes.RunBackUpSourceCopy.main(RunBackUpSourceCopy.java:49) Caused by: java.lang.ClassNotFoundException: javax.mail.MessagingException at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) </code></pre> <p>SendEmail class:</p> <pre><code>public class SendEmail { public String to ; public String from; public String host; public SendEmail(){ to = "xyz@gmail.com"; from = "localhost"; host = "localhost";} public void send_production_email(String reportDate){ Properties properties = System.getProperties(); properties.setProperty("mail.smtp.host", host); Session session = Session.getDefaultInstance(properties); try{ MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress(from)); message.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); message.setSubject("Subject Line!"); message.setText("Test email!"); Transport.send(message); System.out.println("Sent message successfully...."); } catch (MessagingException mex) { mex.printStackTrace(); } } public static void main(String[] args) { System.out.println("Preparing to Send Email ..."); SendEmail email = new SendEmail(); email.send_production_email("test production"); } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload