× 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.



Still getting errors when calling JAVA from within RPG.  I tried to
add the STATIC keyword (methods are all static) without success.

********************************************************************
STILL GET FOLLOWING ERROR WHEN RPG-PROG IS CALLED

 Message ID . . . . . . :   RNQ0301
 Date sent  . . . . . . :   22/02/02      Time sent  . . . . . . :
09:51:45
 Message . . . . :   Java exception received when calling Java method (C G
D
   F).
 Cause . . . . . :   RPG procedure SNDSMTP in program SNDSMTP/PGOOVAERTS
   received Java exception "java.lang.NoSuchMethodError: openSmtpMessage"
when
   calling method "openSmtpMessage" with signature
   "(Ljava.lang.String;)Lcom.company.tools.SendSmtpMail;" in class
   "com.company.tools.SendSmtpMail".
 Recovery  . . . :   Contact the person responsible for program maintenance
to
   determine the cause of the problem.
 Possible choices for replying to message . . . . . . . . . . . . . . . :
   D -- Obtain RPG formatted dump.
   S -- Obtain system dump.

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

********************************************************************
CLASSPATH IS SET AS FOLLOWS AT JOBLEVEL:

'ADDENVVAR' with following routing :'.:/mylib/classes/'
Class is found at '/mylib/classes/com/company/tools/SendSmtpMail.class'

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

********************************************************************
THIS IS HOW IT IS CODED IN RPG

...
 * Declare Object Reference variable and String Object Variables
D obj_ref         S               O   CLASS(*JAVA:'com.company.tools.+
D                                     SendSmtpMail')
D string          S               O   CLASS(*JAVA:'java.lang.String')
D openP1          S               O   CLASS(*JAVA:'java.lang.String')
...
 * Prototype Procedure to create java String object
D newString       PR              O   EXTPROC(*JAVA:'java.lang.String':
D                                     *CONSTRUCTOR)
D                                     CLASS(*JAVA:'java.lang.String')
D charParm                     100A   CONST VARYING

 * Prototype Procedure to instantiate 'sendSmtpMail' class
D sndSmtpObj      PR              O   EXTPROC(*JAVA:'com.company.tools.+
D                                     SendSmtpMail':*CONSTRUCTOR)

 * Prototype Procedure to open the 'sendSmtpMail' mail
D openSmtpObj     PR              O   EXTPROC(*JAVA:'com.company.tools.+
D                                     SendSmtpMail':'openSmtpMessage')
D                                     CLASS(*JAVA:'com.company.tools.+
D                                     SendSmtpMail')
D                                     STATIC
D charParm1                           LIKE(string)
...
...
C/FREE
   eval  openP1 = newString('user');
   eval  obj_ref = sndSmtpObj();
   openSmtpObj(openP1);        // tried CALLP openSmtpObj(openP1) also.
 /END-FREE
********************************************************************

********************************************************************
THIS IS HOW IT IS CODED IN VA-JAVA
import java.io.*;
import sun.net.smtp.SmtpClient;
public class SendSmtpMail
{
      static final String mailServer  = "10.0.0.1";
      static final String fromAdress  = "PGO";
      static final String id          = "AS400-SEND-MAIL";
      static public String toAdress = new String("PGO");
      static public String messageTo;
      static public String messageCc;
      static public String messageBc;
      static public String messageSubject;
      static public SmtpClient smtp;
      static public PrintStream msg;
}

public SendSmtpMail()
{
      super();
}

public static void openSmtpMessage(String sendTo)
{
      setToAdress(sendTo);

      // Create new MailMessage
      try
      {
            smtp = new SmtpClient(getMailServer());
            smtp.from(getFromAdress());
            smtp.to(getToAdress());
            msg = smtp.startMessage();
      }
      catch (IOException e)
      {
            // Write CreateMailError
            Debug.println(DEBUG_LEVEL, id,
"SendSmtpMail_createSmtpMessage", "There was a problem creating mail");
                  e.printStackTrace();
      }
}

THIS IS HOW IT IS TESTED (and works) IN JAVA
Public static void main(String[] args)
{
      // Open message
      openSmtpMessage("user");

      // Create messageHeader
      setMessageTo("emailadress");
      setMessageSubject("subject");
      writeSmtpLine("To:", getMessageTo());
      writeSmtpLine("Subject:", getMessageSubject());

      // Create messageText
      writeSmtpLine("Text", "dataline1");
      writeSmtpLine("Text", "dataline2");
      writeSmtpLine("Text", "dataline3");

      // Close message
      closeSmtpMessage();
}

...
...
********************************************************************




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.