Hi all,
hopefully this should be an easy one to solve! I have just started doing a bit of a refresher on creating JAVA objects and calling their methods from and RPG program. However, I cannot for the life of me remember how all of this stuff worked (or rather does work). I started off with something simple: attempt to retrieve the current time (in milliseconds) from the system.
In JAVA this would simply look like:
I have this in my RPG routine:
Retrieving the system object to call the method from is working fine, but I am falling short on the call to the method implementation. The error I get is:
Now I checked the signature of the method using (JAVAP -S java.lang.System) and this was the result:
I am at a loss as to what I am getting this error, maybe because it is static but I am not sure. Any ideas or comments would be appreciated. Thanks
hopefully this should be an easy one to solve! I have just started doing a bit of a refresher on creating JAVA objects and calling their methods from and RPG program. However, I cannot for the life of me remember how all of this stuff worked (or rather does work). I started off with something simple: attempt to retrieve the current time (in milliseconds) from the system.
In JAVA this would simply look like:
Code:
long milliSeconds = System.currentTimeMillis();
Code:
//=======================================================================* // Variable Declarations * //=======================================================================* dcl-pr System object(*JAVA:'java.lang.System') extproc(*JAVA:'java.lang.System':*CONSTRUCTOR); end-pr; dcl-pr CurrentTime int(20:0) extproc(*JAVA:'java.lang.System':'currentTimeMillis'); end-pr; dcl-s systemObject like(System); dcl-s milliSeconds like(CurrentTime); //=======================================================================* // Program Mainline * //=======================================================================* systemObject = System(); milliSeconds = CurrentTime(systemObject); *inlr = *ON; return; //=======================================================================* // Subroutines * //=======================================================================* begsr *pssr; dump; return; endsr; //=======================================================================*
Code:
Java exception received when calling Java method. RPG procedure SLAVETEST in program QDEVOPLIB/SLAVETEST received Java exception "java.lang.NoSuchMethodError: java/lang/System.currentTimeMillis()J" when calling method "currentTimeMillis" with signature "()J" in class "java.lang.System".
Code:
public static native long currentTimeMillis(); descriptor: ()J
Comment