Like Barbara said, STATIC.
There's nothing wrong with using STATIC procedures (now that I know the syntax :-) ). You don't have to go through the pain of running the CONSTRUCTOR first. If you don't need instance objects, don't use them. Referencing a static method automatically creates the class object the first time you use it, but no instance objects. The class object contains only the static members and methods. But don't call it "main". A class does not have to have a "main" unless you want the RUNJVA command to start there. Java function main is really meant for just that; the place to start when the JVM starts up. You can specify any other function as static. In fact, you can have a static method and non-static method with the same name; they'll have different signatures.
So here's what I'd suggest for your prototype:
ResendOrder pr o STATIC extproc(*JAVA:
'com.WMS_BPCS_Integrator.ex-
ecutable.ResendOrder':'resendOrder')
class(*JAVA:'java.lang.String')
o class(*JAVA:'java.lang.String')
dim(2)
And your method definition should look like this:
String static resendOrder(String[] input{
return "gotcha";
}
I just noticed you're passing in a String array (dim(2)) and not two String's. Of course that's the classic signature for the JVM startup method: static void main(String[] xx)
-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of mikemonger@xxxxxxx
Sent: Tuesday, March 08, 2011 12:12 PM
To: java400-l@xxxxxxxxxxxx
Subject: Re: Signature mismatch when calling java prototype
And that's what I don't understand. You're doing essentially what I'm doing, but with 90 character parms instead of string objects.
Why does your work but mine doesn't? It makes no sense.
-----Original Message-----
From: Dan Kimmel <dkimmel@xxxxxxxxxxxxxxx>
To: Java Programming on and around the IBM i <java400-l@xxxxxxxxxxxx>
Sent: Tue, Mar 8, 2011 12:10 pm
Subject: RE: Signature mismatch when calling java prototype
'm goofing up terminology here: where I said member object, I should have said nstance object.
-----Original Message-----
rom: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-bounces@xxxxxxxxxxxx] On ehalf Of Dan Kimmel
ent: Tuesday, March 08, 2011 10:49 AM
o: Java Programming on and around the IBM i
ubject: RE: Signature mismatch when calling java prototype Here's a working prototype.
* Create the workpiece
dcreateWorkpiece...
d pr 90a extproc(*java :
d 'com.rjssoft.workflow.util.+
d WorkpieceCreationInfo' :
d 'createWorkpiece')
d varying
d user 90a const varying
d password 90a const varying
It takes two byte array parameters and returns a byte array, all 90 characters ong.
When this function is executed from RPG, the member object (newWorkpieceCreationInfo) as already been created and is the first parameter passed. The return value is ewWorkpieceID.
newWorkpieceID =
createWorkpiece...
(newWorkpieceCreationInfo :
%trim(checkinUser) :
%trim(checkinPassword) );
-----Original Message-----
rom: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-bounces@xxxxxxxxxxxx] On ehalf Of mikemonger@xxxxxxx
ent: Tuesday, March 08, 2011 10:18 AM
o: java400-l@xxxxxxxxxxxx
ubject: Re: Signature mismatch when calling java prototype
ee, 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 ariable 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 eports the same signature being sent (String,String)String. Which doesn't make whole lot of sense to me, but, whatever.
I've never had problems calling java classes with prototypes in the past. But his 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 lass. I'm getting the same thing no matter how I define it.
-----Original Message-----
rom: Dan Kimmel <dkimmel@xxxxxxxxxxxxxxx>
o: Java Programming on and around the IBM i <java400-l@xxxxxxxxxxxx>
ent: Tue, Mar 8, 2011 11:07 am
ubject: RE: Signature mismatch when calling java prototype
otice that little word "static" in the definition of your "main" function?
his prototype is trying to invoke the method "main" on a member object. The nction only exists in the class object. Thus, the error, no such method xists.
think there's a way to invoke a static method from RPG, but I've never tried d don't know the syntax.
nother tip: Unless you want to go through another set of Java calls, declare ur function to take and return byte arrays. Byte arrays work just fine in both G and Java so you don't have to go through another set of calls to get the RPG riable from the String.
o your java should look something like this:
byte[] myFunction( byte[] input){
return "Something".getBytes();
----Original Message-----
om: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-bounces@xxxxxxxxxxxx] On half Of mikemonger@xxxxxxx
nt: Tuesday, March 08, 2011 9:11 AM
: java400-l@xxxxxxxxxxxx
bject: Signature mismatch when calling java prototype Ok, I'm officially at my wits end. I've written a java class which accepts an ray of string objects and returns a string. Here is the prototype in the RPG
ogram:
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)
owever, when I call it, I'm receiving the following error:
ause . . . . . : 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".
OW HERE'S THE FUNNY PART.
hen I pull up the class with javap -s, here's what I get for the signatures:
ublic class com.WMS_BPCS_Integrator.executable.ResendOrder extends
va.lang.Object{
blic com.DelMonte.WMS_BPCS_Integrator.executable.ResendOrder();
Signature: ()V
blic static java.lang.String main(java.lang.String[]);
Signature: ([Ljava/lang/String;)Ljava/lang/String;
otice how the signatures match? So do I.
his class works just fine as long as I don't try to RETRIEVE a parm. Removing e return value from both the prototype and the class has the class running rmally.
o...is it possible to actually prototype a java class so that it actually does turn a value to the calling RPG program, or am I banging my head against the ll for nothing?
've tried everything that I can think of so far. I even tried changing it to a onstructor procedure and passing in the parms that way, but it really didn't ke that.
-
is is the Java Programming on and around the IBM i (JAVA400-L) mailing list To st a message email: JAVA400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or hange ist options,
sit:
http://lists.midrange.com/mailman/listinfo/java400-l
email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a moment to view the archives at
http://archive.midrange.com/java400-l.
--
is is the Java Programming on and around the IBM i (JAVA400-L) mailing list o ost a message email: JAVA400-L@xxxxxxxxxxxx o subscribe, unsubscribe, or change ist options,
sit:
http://lists.midrange.com/mailman/listinfo/java400-l
email: JAVA400-L-request@xxxxxxxxxxxx
fore posting, please take a moment to review the archives t ttp://archive.midrange.com/java400-l.
-
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.
--
his is the Java Programming on and around the IBM i (JAVA400-L) mailing list o post a message email: JAVA400-L@xxxxxxxxxxxx o subscribe, unsubscribe, or change list options,
isit:
http://lists.midrange.com/mailman/listinfo/java400-l
r email: JAVA400-L-request@xxxxxxxxxxxx
efore posting, please take a moment to review the archives t
http://archive.midrange.com/java400-l.
--
his is the Java Programming on and around the IBM i (JAVA400-L) mailing list o post a message email: JAVA400-L@xxxxxxxxxxxx o subscribe, unsubscribe, or change list options,
isit:
http://lists.midrange.com/mailman/listinfo/java400-l
r email: JAVA400-L-request@xxxxxxxxxxxx
efore posting, please take a moment to review the archives t
http://archive.midrange.com/java400-l.
As an Amazon Associate we earn from qualifying purchases.