Problem with RPG Prototype for java.io.File

I'm attempting to work with jsoup in RPGLE, but I don't know a lot about Java. I can't get past trying to create a java.io.File object to use in jsoup. I'm obviously doing something wrong, but I just can't seem to figure out what.

Here's my code:

       // Create Java String Object
       Dcl-Pr newString Object(*Java:'java.lang.String')
         *N Varchar(32767) Const;

       // Create Java File Object
       Dcl-Pr newFile Object(*Java:'java.io.File')
         *N Object(*Java:'java.lang.string');

       Dcl-S String Object(*Java:'java.lang.string');
       Dcl-S File Object(*Java:'java.io.File');

       String = newString('/java/jsoup/46525580.html');
       File = newFile(String);

The String object is created successfully. I verified that using String.getBytes and returning the data back into an alpha field. However, the newFile call throws an RNQ0301 error message:

Message . . . . :   Java exception received when calling Java method (C G D   
Cause . . . . . :   RPG procedure JSOUP in program RLSTESTLIB/JSOUP received  
  Java exception "java.lang.NoSuchMethodError:                                
  java/io/File.<init>(Ljava/lang/string;)V" when calling method "<init>" with 
  signature "(Ljava.lang.string;)V" in class "java.io.File".                  

What am I doing wrong here? The prototype I created for the java.io.File constructor is obviously wrong, but I'm not familiar enough with Java to figure it out.


  • @nfgl is correct, the class ‘String’ needs to start with an uppercase S.

    As a side note, that error is usually the result of a classpath error.

    Suggestion: rather than put a lot of Java calls in your RPG code, create a single Java class (in RDi) to perform the detailed operations. Then just invoke that Java from the RPG.