ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Calling Java main method in RPGLE

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Calling Java main method in RPGLE

    Hi,

    I am trying to call a Java Main method from my RPGLE program by using prototyping. But I am getting the following error.


    Message . . . . : Parameter 1 received a Java exception on conversion to a
    Java array (C G D F).

    Cause . . . . . : RPG procedure APPJAVALE in program SPLIB/APPJAVALE
    received Java exception java.lang.NoClassDefFoundError:
    com/app/mad/digitalphotocard/actions/StartApplication when converting an
    RPG parameter to a Java array. The error occurred for parameter number 1
    for the call to Java method "main" in class
    "com.app.mad.digitalphotocard.actions.StartApplica tion".

    Any pointers to the cause and recovery of this error would be very helpful.

    I think the cause of the problem is that the java main method:
    public static void main(String[] args) is not being prototyped and called correctly in the RPGLE program. But I am not able to figure out the correct way. Please help.

    Thanks,
    Subha.

  • #2
    Re: Calling Java main method in RPGLE

    You cannot prototype the main method of a java program. If you are trying to execute the main you need to execute QCMDEXEC or use the system command as follows:

    PHP Code:
    Hbnddir('QC2LE')
    D  GoCmd          Pr            10I 0 Extproc('system')                                        
    D    cmdString                    *   Value                                                    
    D                                     Options
    (*String)                                         
    D ReturnCode      S             10I 0   
    D QUOTE             C                   
    const('''')                                                       
     /
    Free

        ReturnCode 
    GoCmd'RUNJVA CLASS(MyClass)'             +
                              
    ' PARM( ' +QUOTEparm1 +QUOTE+
                                +
    QUOTEparm2 +QUOTE
                                +
    QUOTE+  parm3 +QUOTE')'     ); 
        
        If 
    ReturnCode 0;
          
    Dsply 'Success';
        Else;
          
    Dsply 'Error';
        EndIf;

        *
    InLr = *On;
        Return;

     /
    End-Free 
    Last edited by kpmac; April 27, 2006, 07:41 AM.
    Predictions are usually difficult, especially about the future. ~Yogi Berra

    Vertical Software Systems
    VSS.biz

    Comment


    • #3
      Re: Calling Java main method in RPGLE

      Actually, its possible to prototype and call the Java main method. Just follow this link which tells how to call Java main methods from RPG. I have myself tried the programs in this web-page and I got the correct output.




      Thanks,
      Subha.

      Comment


      • #4
        Re: Calling Java main method in RPGLE

        Wow, I did not know that.

        Can you explain to me the benefits gained from prototyping the main method vs. invoking the application via runjva?

        The example on the site seems more complicated to me and also creates numerous objects that need to be cleaned up afterwords.
        Predictions are usually difficult, especially about the future. ~Yogi Berra

        Vertical Software Systems
        VSS.biz

        Comment

        Working...
        X