× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



"Bramley, Stu" wrote:
> 
> I'm trying to put together some 'Hello World' code that will call the Java
> method System.out.println(String) from RPG - however I'm struggling to get
> this defined correctly in the RPG..
> 
> I have tried the following :
> 
> D println         PR                  EXTPROC(*JAVA :
> D                                     'java.lang.System.out':
> D                                     'println')
> D                                     STATIC

Stu, "out" isn't part of the class; it's a PrintStream field in the
Static class.  'println' is an instance method in the PrintStream
class.  http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html

D println         PR                  EXTPROC(*JAVA :
D                                     'java.io.PrintStream':
D                                     'println')                     
D  inString                       O   CLASS(*JAVA : 'java.lang.String')

To make this call, you need to get hold of the System field "out".  

D out             S               O   CLASS(*JAVA :
'java.io.PrintStream')
...
         println (out : string)

I think you might have to write a little Java method to return it; RPG
can only access methods, not fields (at least using the EXTPROC(*JAVA)
support).  The ILE RPG programmer's guide does have an example of doing
the JNI calls to access fields, so you could try that to get the "out"
field from System.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 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.