|
If I move the JavaMail.class file to another 400 (a 270 also running V5R1)
and call it, I get the following message:
Warning: JIT compiler "jitc_de" not found. Will use interpreter.
java.lang.UnsatisfiedLinkError: no zip in java.library.path
... then a whole bunch of errors ...
Is the JIT compiler a product that needs to be installed? If so, what is
the product code?
Mike E.
MEovino@estes-expr
ess.com To: java400-l@midrange.com
Sent by: cc:
java400-l-admin@mi Subject: JavaMail API - null
pointer exception
drange.com
05/14/2002 11:09
PM
Please respond to
java400-l
I'm having trouble trying to implement the JavaMail API on our 400 (an 830
running V5R1, most likely not very up-to-date on PTF's).
I'm working with Bob Cancilla and some others on Ignite400 to come up with
a tutorial for writing an RPG wrapper for JavaMail (you can see what I've
done so far here:
http://www.estes-express.com/rpgjavamail/instructions.html)
Anyway, the Java program is throwing an exception, so I'm trying to call it
from the command line in QSH.
Here is the stack trace when it catches the exception:
java.lang.NullPointerException
javax/mail/Transport.send0(Ljavax/mail/Message;[Ljavax/mail/Address;)V+
0 (Transport.java:109)
javax/mail/Transport.send(Ljavax/mail/Message;)V+0
(Transport.java:79)
JavaMail.sendMail(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String
;Ljava/lang/String;Ljava/lang/String;)S+0 (JavaMail.java:33)
JavaMail.main([Ljava/lang/String;)V+0 (JavaMail.java:14)
Here is the code (please note, this will not match the JavaMail.java file
on my site):
/*******************************************************************************************
Date : 11/02/2001
Programmer : James Zhang
Desc : Practice the javamail.
********************************************************************************************/
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
import java.io.*;
public class JavaMail {
public static void main (String args[]) throws Exception {
String from = args[0];
String to = args[1];
String replyTo = args[2];
String subject = args[3];
String text = args[4];
short returnCode = 0;
try{
returnCode = sendMail(from,to,replyTo,subject,text);
}catch(Exception e){
e.printStackTrace();
}
}
public static short sendMail (String from, String to, String replyTo,
String subject,String text) throws
Exception {
try{
//get the properties
FileInputStream emailPropertyFile;
//get the properties
Properties emailProperty = new Properties();
try{
emailPropertyFile = new FileInputStream
("JavaMail.properties");
}catch(FileNotFoundException e){
//JZEmail.properties not found
return 100;
}
emailProperty.load(emailPropertyFile);
emailPropertyFile.close();
//String host = "SMTP.RICAINS.COM";
String hostName = emailProperty.getProperty("email.hostname");
String hostType = emailProperty.getProperty("email.hosttype");
// Get system properties
Properties systemProperty = System.getProperties();
// Setup mail server
systemProperty.put(hostType, hostName);
// Get session
Session session = Session.getDefaultInstance(systemProperty, null);
//Session session = Session.getInstance(systemProperty, null);
// Define message
MimeMessage message = new MimeMessage(session);
// Set the from address
message.setFrom(new InternetAddress(from));
// Set the to address
message.addRecipient(Message.RecipientType.TO, new
InternetAddress(to));
// Set the subject
message.setSubject(subject);
// Set the content
message.setText(text);
// Set the reply to
replyTo = replyTo.trim();
if(replyTo != null && !replyTo.equals("")){
InternetAddress ReplyTo[] = new InternetAddress[1];
ReplyTo[0] = new InternetAddress(replyTo);
message.setReplyTo(ReplyTo);
}
// Send message
Transport.send(message);
}catch(MessagingException me){
// search for the real exception that caused the problem
Exception realException = me;
while ( (realException instanceof MessagingException) &&
((MessagingException)realException).getNextException() !=
null) {
realException =
((MessagingException)realException).getNextException();
}
// map the exceptions to error codes
if (realException instanceof javax.mail.MessagingException)
return 101;
else if (realException instanceof java.net.ConnectException)
return 102;
else if (realException instanceof java.net.UnknownHostException)
return 103;
}catch(Exception e){
// filename is not found
e.printStackTrace();
return 999;
}
return 0;
}
}
Here is my CLASSPATH:
/JavaUtil/JavaMail/activation.jar:/JavaUtil/JavaMail/imap.jar:/JavaUtil/JavaM
ail/mail.jar:/JavaUtil/JavaMail/mailapi.jar:/JavaUtil/JavaMail/smtp.jar:/Java
Util/JavaMail/
Here is how I'm calling the program:
java JavaMail meovino@estes-express.com webmaster@estes-express.com
meovino@estes-express.com "this is subject 4" "this is the body"
Also, I have imported this code, activation.jar and mail.jar into VA for
Java, set the CLASSPATH accordingly, and it all works on my PC. If I
export the JavaMail.class and move it to the 400, I get the same exception.
This is the first thing I've ever really tried to do (other than "hello
world" stuff) in Java, so I apologize in advance if I've missed something
basic.
Thanks in advance!
Mike E.
_______________________________________________
This is the Java Programming on and around the iSeries / AS400 (JAVA400-L)
mailing list
To post a message email: JAVA400-L@midrange.com
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l
or email: JAVA400-L-request@midrange.com
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.