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




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
xists.
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
rogram:
d ResendOrder pr o extproc(*JAVA:
'com.WMS_BPCS_Integrator.ex-
ecutable.ResendOrder':'main')
class(*JAVA:'java.lang.String')
o class(*JAVA:'java.lang.String')
dim(2)
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
"com.WMS_BPCS_Integrator.executable.ResendOrder".
NOW HERE'S THE FUNNY PART.
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
ava.lang.Object{
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.
So...is 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,
isit: http://lists.midrange.com/mailman/listinfo/java400-l
r email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a moment to
eview the archives at http://archive.midrange.com/java400-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.