ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Noobiee question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Noobiee question

    Guys,
    I'm befinning to learn Java on the iSeries. I have a very basic question, pardon my noooobieness please.
    I know that Java uses the IFS to keep classes and other stuff that need to run a program. I was wondering if there is a way to create a object (like a service pgm), and bind it to my RPG program and run it, without having to go to IFS each time.
    Thanks

  • #2
    Re: Noobiee question

    No way that I know of. There is a CRTJVAPGM command but it doesn't create a program like an RPG program that you can just CALL. It think it's a system performance thing, I've yet to find anyone who can explain it properly.

    You can of course bundle your classes up into a jar file. Then you would only have to add that one file to your classpath before execution.
    Ben

    Comment


    • #3
      Re: Noobiee question

      you could reference your java classes, etc via RPG by defining the classes through prototyping like so:
      Code:
      djInputStream     s               o   Class(*JAVA               
      d                                     :'java.io.InputStream')
      that represents an java InputStream object.
      to define the constructor it would look like this:
      Code:
      dnew_InputStream  pr                  ExtProc(*JAVA             
      d                                     :'java.io.InputStream'    
      d                                     :*CONSTRUCTOR)            
      d                                     like(jInputStream)
      in your program/service program to create an object of InputStream type you can define as:
      Code:
      doutInputStream...                                              
      d                 s                   like(jInputStream)
      then to instantiate the object:
      Code:
       /free
         outInputStream = new_InputStream;
      now you have a java object called outInputStream.

      you can look for the redbook on IBM's website for the RPG and eBusiness and i think it's also in the Who knew you could do that in RPG? redbook(JonBoy can tell us for sure if it's in there.
      I'm not anti-social, I just don't like people -Tommy Holden

      Comment


      • #4
        Re: Noobiee question

        The RPG theory there is sound but I doubt that code would work. InputStream is an abstract class so you can't create an object of that type.

        An abstract class is like an interface in that you can declare abstract methods with no implementation. Also like an interface you cannot instantiate an object of that type. Unlike an interface you can declare constructors, attributes and concrete methods. Also, since it is a class, any sub-class must extend rather than implement it. This means no polymorphism like with an interface. I.E. You can only extend one abstract class in a sub class.
        Ben

        Comment


        • #5
          Re: Noobiee question

          Originally posted by BenThurley View Post
          The RPG theory there is sound but I doubt that code would work. InputStream is an abstract class so you can't create an object of that type.

          An abstract class is like an interface in that you can declare abstract methods with no implementation. Also like an interface you cannot instantiate an object of that type. Unlike an interface you can declare constructors, attributes and concrete methods. Also, since it is a class, any sub-class must extend rather than implement it. This means no polymorphism like with an interface. I.E. You can only extend one abstract class in a sub class.
          i just posted that as a reference as to how it would look. i didn't take the time to dig for a better example...
          I'm not anti-social, I just don't like people -Tommy Holden

          Comment

          Working...
          X