See, here's the funny part about that static keyword.

If I don't include it, the program won't compile unless I include the return variable as the first parameter in the prototype call.

But when I do that....I get the exact same error. And what's funny is that it reports the same signature being sent (String,String)String. Which doesn't make a whole lot of sense to me, but, whatever.

I've never had problems calling java classes with prototypes in the past. But this is the first time that I've actually tried to get something back from one.

And the issue doesn't seem to be whether to method is static or not in the class. I'm getting the same thing no matter how I define it.

-----Original Message-----
From: Dan Kimmel <dkimmel@xxxxxxxxxxxxxxx>
To: Java Programming on and around the IBM i <java400-l@xxxxxxxxxxxx>
Sent: Tue, Mar 8, 2011 11:07 am
Subject: RE: Signature mismatch when calling java prototype

otice that little word "static" in the definition of your "main" function?
This prototype is trying to invoke the method "main" on a member object. The
unction only exists in the class object. Thus, the error, no such method
I think there's a way to invoke a static method from RPG, but I've never tried
nd don't know the syntax.
Another tip: Unless you want to go through another set of Java calls, declare
our function to take and return byte arrays. Byte arrays work just fine in both
PG and Java so you don't have to go through another set of calls to get the RPG
ariable from the String.
So your java should look something like this:
byte[] myFunction( byte[] input){
return "Something".getBytes();

----Original Message-----
rom: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-bounces@xxxxxxxxxxxx] On
ehalf Of mikemonger@xxxxxxx
ent: Tuesday, March 08, 2011 9:11 AM
o: java400-l@xxxxxxxxxxxx
ubject: Signature mismatch when calling java prototype

Ok, I'm officially at my wits end. I've written a java class which accepts an
rray of string objects and returns a string. Here is the prototype in the RPG
d ResendOrder pr o extproc(*JAVA:
o class(*JAVA:'java.lang.String')
However, when I call it, I'm receiving the following error:
Cause . . . . . : RPG procedure GWBA09D5 in program MXMLIB/GWBA09D5 received
Java exception "java.lang.NoSuchMethodError: main" when calling method
"main" with signature "([Ljava.lang.String;)Ljava.lang.String;" in class
When I pull up the class with javap -s, here's what I get for the signatures:
public class com.WMS_BPCS_Integrator.executable.ResendOrder extends
ublic com.DelMonte.WMS_BPCS_Integrator.executable.ResendOrder();
Signature: ()V
ublic static java.lang.String main(java.lang.String[]);
Signature: ([Ljava/lang/String;)Ljava/lang/String;

Notice how the signatures match? So do I.
This class works just fine as long as I don't try to RETRIEVE a parm. Removing
he return value from both the prototype and the class has the class running
ormally. it possible to actually prototype a java class so that it actually does
eturn a value to the calling RPG program, or am I banging my head against the
all for nothing?
I've tried everything that I can think of so far. I even tried changing it to a
constructor procedure and passing in the parms that way, but it really didn't
ike that.
his is the Java Programming on and around the IBM i (JAVA400-L) mailing list To
ost a message email: JAVA400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or
hange list options,
r email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a moment to
eview the archives at

This thread ...


Return to Archive home page | Return to MIDRANGE.COM home page