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



I'm trying to call a Java method to Decode a Base64 string from within an
RPG Subprocedure.
javap -s shows this:
 $
 javap -s com.twiek.Utils.Base64
 Compiled from Base64.java
 public final class com.twiek.Utils.Base64 extends java.lang.Object {
     public static final java.lang.String encode(java.lang.String);
         /*   (Ljava/lang/String;)Ljava/lang/String;   */
     public static final java.lang.String decode(java.lang.String);
         /*   (Ljava/lang/String;)Ljava/lang/String;   */
 }
 $

I'm assuming that this means that the method deocde accepts a java string
object and returns a java string object.

Here is my code.
     Hoption(*nodebugio:*srcstmt) NOMAIN  thread(*serialize)

     DdecodeBase64     PR         32767    varying
     D inputString                32767    const

     DstringObject     S               O   class(*JAVA:'java.lang.String')

     Dbase64Class      S               O   class(*JAVA:'com.twiek.Utils.-
     D                                     Base64')

     DnewString        PR              O
extproc(*JAVA:'java.lang.String':
     D                                     *CONSTRUCTOR)
     D                            32767a   const varying options(*varsize)

     DnewBase64Class   PR              O   extproc(*JAVA:'com.twiek.Utils.-
     D                                     Base64':*CONSTRUCTOR)


     Ddecode           PR              O   extproc(*JAVA:'com.twiek.Utils.-
     D                                     Base64':'decode')
     D                                     class(*JAVA:'com.twiek.Utils.-
     D                                     Base64')


     DgetBytes         PR         32767a
extproc(*JAVA:'java.lang.String':
     D                                     'getBytes') varying




     PdecodeBase64     B                   Export
     DdecodeBase64     PI         32767    varying
     D inputString                32767    const

     DoutputString     S                   like(decodeBase64)

      /free

       base64Class = newBase64Class();
       stringObject = newString(%trim(inputString));
       stringObject = decode(stringObject);
       outPutString = getBytes(stringObject);

       return outputString;
      /end-free
     P                 E

The base64 class and stringObject instatiate fine but when I get to calling
the decode method, I get java.lang.NoSuchMethodError exception.

Any idea why?

Thanks,

Mark

Mark D. Walter
Senior Programmer/Analyst
CCX, Inc.
mwalter@xxxxxxxxxx
http://www.ccxinc.com


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.