× 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.



SRamanujan=dsjOEj4+x6mynpMCO8VUG9BPR1lH4CV8@public.gmane.org wrote:
>
> Thanks Barbara.  I am sure I did something wrong!..  Here's what I am trying 
>to do.  I am trying to create a 'url' instance of java.net.URL class with 
>whatever I am passing in as a parm.  In Java, we would call the method as url 
>= new URL(); and url.getHost(); but now, I am confused in AS/400.  Should I 
>enter Class2 (to refer to my instance) as 'java.net.URL url' or plain url or 
>'java.net.URL'?

Sudha, your Java code would look something like this:

   URL ur1;
   String host;

   ur1 = new URL();
   host = url.getHost();

In RPG it's similar.  To declare an object variable
   SomeClass someobj;
you code
   D someobj      S       O   CLASS(*JAVA:'SomeClass')
although if the class is in a package, like all the Java classes are,
you have to code the package info:
   D someobj      S       O   CLASS(*JAVA:'java.whatever.SomeClass')
or D someobj      S       O   CLASS(*JAVA:'Mypkg.SomeClass')

The RPG prototype for the method has to exactly match the Java version.
For example, if the method returns a String, you must code a String
object as the return value in the RPG prototype.

>  I tried the java.net.URL and since it is not a static method, and I just 
>call getHost(), the the rpgle does not compile, the error is
>
>   Msg id  Sv Number Seq     Message text
>  *RNF7588 30     81 008900  The call to Java method GETHST requires an object 
>as the
>                             extra first parameter.

For non-static methods, you have to pass the instance object as the
first parameter.

Say you have a Java method in class ABC    int getVal (int option);
In RPG, you would prototype it like this:
   D getVal    PR      10i 0  EXTPROC(*JAVA:'ABC':'getVal')
   D  option           10i 0  VALUE

There's only one parameter listed in the prototype, same as the Java.

In Java, you would call it like this:
     x = anAbc.getVal(3);
In RPG, you call it like this, passing the instance as the first
parameter:
     x = getVal(anAbc : 3);
So for a non-static method, you always pass one more parameter than is
listed in the RPG prototype.

>
> (Is there a manual I could refer to, for these codes?)
>

The ILE RPG Programmer's Guide, chapter 11, section "RPG and Java".
http://publib.boulder.ibm.com/iseries/v5r2/ic2924/books/c0925074.pdf




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.