|
I am following these steps:
1. MD DIR(java)
2. CRTSRCPF MYLIB/QJAVASRC
3. Creating a member called test in QJAVASRC
open the member in edit mode and
do - "S caps off" at the top of the seu to allow lower case
4.Then i write this java program in member 'test'.
public class test {
static String mystring;
public static String setMyString(String s) {
mystring = s + "prog";
return mystring;
}
}
5. CPYTOSTMF FROMMBR('/qsys.lib/ablib.lib/qjavasrc.file/test.mbr')
TOSTMF('/java/test.java') STMFCODPAG(*PCASCII)
6. wrklnk java
7. take option 5 and see the test.java there
8. qsh
9. javac /java/test.java
10. wrklnk java (see if the class file is created or not)
11. create a RPGLE member in QRPGLESRC called TESTJAVA
This is my RPGLE program TESTJAVA which calls the Java method setMyString
described in the above Java program:
Code:
D setMyString PR o class(*java:'java.lang.String')
D extproc(*java:
D 'test':'setMyString')
D static
D mystring o class(*java:'java.lang.String')
*
D makeString PR o extproc(*java:'java.lang.String':
D *constructor)
D bytes 65000a const varying
*
D getBytes PR 100a Varying
D extproc(*java
D :'java.lang.String'
D :'getBytes')
*
D string s o class(*java:'java.lang.String')
D bytes2 s 20a varying
/free
string = makestring('This is a test ');
string = setMyString(string);
bytes2 = getBytes(string);
dsply bytes2;
return;
14. Compile the program
15. ADDENVVAR ENVVAR(CLASSPATH) VALUE('/JAVA')
16. call the RPGLE program
When i first compiled and ran this program by doing CALL TESTJAVA, I got my
output as "This is a test prog".
But after that whenever i CALL TESTJAVA , I get an error:
Java exception received when calling Java method (C G D F).
Application error. RNX0301 unmonitored by TESTJAVA at statement 0000000021
Line 21 is the line which calls setMystring,i.e.
string = setMyString(string)
If anyone can give me some pointers about the reason for this error it will be
very helpful.
Thanks.
H DftActGrp(*NO) ActGrp(*CALLER)
D setMyString PR o class(*java:'java.lang.String')
D extproc(*java:
D 'test':'setMyString')
D static
D mystring o class(*java:'java.lang.String')
*
D makeString PR o extproc(*java:'java.lang.String':
D *constructor)
D bytes 65000a const varying
*
D getBytes PR 100a Varying
D extproc(*java
D :'java.lang.String'
D :'getBytes')
*
D string s o class(*java:'java.lang.String')
D bytes2 s 20a varying
/free
string = makestring('This is a test ');
string = setMyString(string);
bytes2 = getBytes(string);
dsply bytes2;
return;
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.