|
Barbara, Thanks for the reply. It compiles fine, but now something strange is happening. My RPG program has two parms D file_in S 255 D format S 10I 0 And I'm trying to call it from the command line with the following command: CALL PGM(ICR001) PARM('/JavaUtil/ImageConversion/in' 13) In calling it from the command line, I am getting garbage in file_in, because I'm not padding it out to 255 characters with blanks. If I clean it up by looking for the first blank and substringing out everything before that and putting the result back in file_in, I get exception "java.lang.NoSuchMethodError:" when calling method "<init>" with signature (Ljava.io.file;I)V" in class "conversionTest". If I comment out the cleanup stuff, it runs, but it obviously does not find the correct directory. If I define file_in as D file_in S 255A Varying I get a "Length of varying length variable is out of range" error. If I look at the dump, it tells me that file_in is 257 characters long. Mike E. Barbara Morris <bmorris@ca.ibm.c To: rpg400-l@midrange.com om> cc: Sent by: Subject: Re: Prototyping and Creating integer objects in RPG for rpg400-l-admin@mi callingJavaclasses drange.com 11/22/02 10:26 AM Please respond to rpg400-l meovino=/SPx079MrvAgMxX8nMqP6gC/G2K4zDHf@public.gmane.org wrote: > > I have re-read the chapter several times, and it looks as if I need to call > the Java method passing an instance parameter as the first parm. > Unfortunately, the book does not appear to give any examples of calling a > non-static method that does not return a value. The method is defined as > follows: > > public class conversionTest > { > > public conversionTest(File f, int format) > Ok, I get it now. A method whose name is the same as the class name is called a "constructor". It returns an object of the class. In RPG, you prototype it with the special method name *CONSTRUCTOR, and define it to return an object. (But you don't have to code the CLASS keyword for the return value.) D Class1 C 'conversionTest' * conversionTest constructor * Java: public conversionTest(File f, int format); D newConversionTest... D PR O ExtProc(*JAVA: D Class1:*CONSTRUCTOR) * method parameters D f O Class(*JAVA:'java.io.File') D Const D format 10I 0 Value D obj S O Class(*JAVA:Class1) c eval obj = newConversionTest (fFile : format) It's a good idea to put the Java version of the method header as a comment in the RPG. Sorry if I was a bit snarky before. As well as reading about RPG and Java, I think it's important for you to read a bit about Java. Sun has a nice tutorial here: http://java.sun.com/docs/books/tutorial/java/index.html. _______________________________________________ This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l or email: RPG400-L-request@midrange.com Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.
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.