Midrange News for the IBM i Community

Posted by: Ajay Kulkarni
RPG call JAVA via JNI
has no ratings.
Published: 05 Nov 2012
Revised: 23 Jan 2013 - 4138 days ago
Last viewed on: 23 May 2024 (5525 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

RPG call JAVA via JNI Published by: Ajay Kulkarni on 05 Nov 2012 view comments(1)


What is the difference between endObjGroup and freelocalref? Which one to use when (small example)? Can we find out if the JVM is active and which objects are still part of the JVM  (objects not destroyed)?


Return to midrangenews.com home page.
Sort Ascend | Descend


(Sign in to Post a Comment)
Posted by: DaleB
Premium member *
Reading, PA
Comment on: RPG call JAVA via JNI
Posted: 11 years 6 months 17 days 18 hours 19 minutes ago

You should look at the ILE RPG Programmer's Guide, SC09-2507. At V6R1 see Chapter 11. RPG and the eBusiness World; the there's a fairly comprehensive section on RPG and Java.

As I understand it, JVM won't do garbage collection on things created from RPG using JNI. freelocalref() frees up a single object (RPG type O). endObjGroup() will do the equivalent free on all objects back to the last strObjGroup(). See the manual for example.

To find if JVM is active, you could try to get the JNI environment pointer, but the problem with this is it will create the JVM if it's not already started. Maybe someone else knows a way that queries it without that side effect?