× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Guru's,
I am running into a an error trying to execute a piece of Java code from my
iSeries. I can run it just fine from my pc. Any help in this matter would be
much appreciated. Here is the error that I am getting..

****************************************************

  FATAL ERROR in native method: Received NULL object reference
  java.lang.Throwable
  Java program completed with exit code 134

******************************************************

My code:
***************************************************************
import java.io.IOException;
import java.io.PrintStream;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.internet.MimeMessage;

import sun.net.smtp.SmtpClient;


public class accptargs4

{

           public static void main(String[] args)

                   throws IOException, StringIndexOutOfBoundsException,
MessagingException

               {
                   Calendar cal = new GregorianCalendar();

                   Date mydate = cal.getTime();

                   String mydatestring = mydate.toLocaleString();

               String from = "MessagesSystem@xxxxxxxxxxxxxxxx";


               //String to = args[0];
               String to = "jakem@xxxxxxxxxxxxxxxx";



               //String subject = args[1];
               String subject = "test";


               //String messagetxt = args[2];
               String messagetxt = "test";

               SmtpClient client = new SmtpClient("mail.bwicompanies.com");

               client.from(from);



               client.to(to);


               java.util.Properties props = new java.util.Properties();

               String smtpHost = "mail.bwicompanies.com";
               String smtpPort = "25";
               props.put("mail.smtp.host", smtpHost);
               props.put("mail.smtp.port", ""+smtpPort);
               Session session = Session.getDefaultInstance(props,null);
               Message msg = new MimeMessage(session);

               msg.setSentDate(mydate);


               PrintStream message = client.startMessage();

             message.println("To: "+to);
             message.println("Received:" +new Date());
             message.println("Subject:" + subject);
             message.println();
             message.println("This is a test message.");
             message.println("Body:");
             message.println();
             int msgarraysize = messagetxt.length();
             String str = new String(messagetxt);
             char charArray[] = new char[ 78 ];
             int getnumchars = 78;
             for(int i = 0; i < (msgarraysize); i+=78)
               {

                   while(getnumchars < (msgarraysize ))

                       {
                               str.getChars(i, getnumchars, charArray, 0);
                               System.out.println(charArray);
                               message.println(charArray);
                               System.out.println(i);
                               i+=78;
                               getnumchars+=78;
                       }

           if   (i < msgarraysize)

               {
                   for(int k = 0; k < charArray.length;k++)
                       {
                           charArray[k] = ' ';
                       }
               str.getChars(i, (msgarraysize), charArray, 0);
               System.out.println(charArray);
               message.println(charArray);
               System.out.println(i);

                       }

                       }



               message.println();

               message.println();

               message.close();

               client.closeServer();

               System.out.println("Email Was Sent!!");

               System.out.println(messagetxt.length());

               System.out.println(charArray.length);

               System.out.println(messagetxt);
                   int hour12 = cal.get(Calendar.HOUR);            // 0..11
                   int hour24 = cal.get(Calendar.HOUR_OF_DAY);     // 0..23
                   int min = cal.get(Calendar.MINUTE);             // 0..59
                   int sec = cal.get(Calendar.SECOND);             // 0..59
                   int ms = cal.get(Calendar.MILLISECOND);         //
0..999
                   int ampm = cal.get(Calendar.AM_PM);             // 0=AM,
1=PM

                   System.out.println("DateOfMine :" + mydatestring);






               }

}

****************************************************************************************

Thanks a bunch in advance,

cheers,

Jake.

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 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.