Blog Archive

iSeries Java exception java.lang.NoSuchMethodError - AS400 Message ID RNX0301

iSeries fix for No such Method found error when calling Java program from RPGLE

When calling a Java program from RPGLE you must define prototype for each Method that you want to call from your RPGLE program. The Java program may have lot of methods defined but you don't have to prototype all of them, only the ones that you want to call from your RPGLE program. Let take a sample Java program and see how we can define prototypes for the methods in it.

Sample Java Program

package com.as400samplecode; 

 public class CallThis { 

  public static void main(String[] args) { 
  String result = myproc("as400samplecode"); 


 public static String myproc(String abc) { 

  String xyz = abc; 
  return xyz; 


 public static void myvoid(String abc) { 

  String xyz = abc; 



RPGLE prototype definitions for the CallThis Java Program

 * Prototype for CallThis's myproc Method                              
d myproc          PR              o   EXTPROC(*JAVA:                   
d                                             'com.as400samplecode.CallThis':              
d                                             'myproc')                
d                                     Class   (*JAVA:'java.lang.String')
d                                             STATIC                   
d String                          o   Class   (*JAVA:'java.lang.String')
d                                             Const                    
 * Prototype for CallThis's myproc Method                              
d myvoid          PR                  EXTPROC(*JAVA:                   
d                                             'com.as400samplecode.CallThis':              
d                                             'myvoid')                
d                                             STATIC                   
d String                          o   Class   (*JAVA:'java.lang.String')
d                                             Const                     

How to check Methods defined in Java Class to match signature

Go to into Qshell using command QSH and press ENTER

Change directory to the class object using cd /directory1/directory2/..

Use command javap -s com.as400samplecode.callThis

Output when you run the above command
Compiled from ""                                            
public class com.as400samplecode.CallThis extends java.lang.Object{      
public com.as400samplecode.CallThis();                                   
  Signature: ()V                                                         
public static void main(java.lang.String[]);                             
  Signature: ([Ljava/lang/String;)V                                      
public static java.lang.String myproc(java.lang.String);               
  Signature: (Ljava/lang/String;)Ljava/lang/String;                    
public static void myvoid(java.lang.String);                           
  Signature: (Ljava/lang/String;)V     

javap command options include

   -b                        Backward compatibility with javap in JDK 1.1   

   -c                        Disassemble the code                           

   -classpath <pathlist>     Specify where to find user class files                 

   -extdirs <dirs>           Override location of installed extensions              

   -help                     Print this usage message                               

   -J<flag>                  Pass <flag> directly to the runtime system             

   -l                        Print line number and local variable tables            

   -public                   Show only public classes and members                   

   -protected                Show protected/public classes and members              

   -package                  Show package/protected/public classes                  

                             and members (default)                                  

   -private                  Show all classes and members                           

   -s                        Print internal type signatures                         

   -bootclasspath <pathlist> Override location of class files loaded                

                             by the bootstrap class loader                          

   -verbose                  Print stack size, number of locals and args for methods

                             If verifying, print reasons for failure