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




Just a couple of comments regarding Java basics. Dan probably covered
them below, but:

1. By convention, the Java runtime finds the starting point of an
application by invoking a main() method with this signature:

public static void main( String[] args )

If such a method doesn't exist, a standard runtime ( invoking java
MyOwnClass or the RUNJAVA equivalent ) won't start the app and returns a
NoSuchMethodError.

You can have multiple methods ( with different signatures, like any
other method ) *OR* no methods named main. The reasons normally cited are
method overloading/overriding, or that an object may be intended to only be
instantiated by methods from other classes, so it doesn't need a main()
method.

2. A static method doesn't need an instance; it's available at class
load time. But, although it's frowned upon, you *can* still call a static
( that is, a class ) method via an instance. i.e.

MyOwnClass moc = new MyOwnClass();

moc.myStaticMethod();

That's likely due to inheritance, but in implementations the compiler
probably just realizes a static method is being requested and substitutes
the appropriate call.

HTH,


Joe Sam

Joe Sam Shirah - http://www.conceptgo.com
conceptGO - Consulting/Development/Outsourcing
Java Filter Forum: http://www.ibm.com/developerworks/java/
Just the JDBC FAQs: http://www.jguru.com/faq/JDBC
Going International? http://www.jguru.com/faq/I18N
Que Java400? http://www.jguru.com/faq/Java400

----- Original Message ----- From: "Dan Kimmel" <dkimmel@xxxxxxxxxxxxxxx>
To: "Java Programming on and around the IBM i" <java400-l@xxxxxxxxxxxx>
Sent: Tuesday, March 08, 2011 1:44 PM
Subject: RE: Signature mismatch when calling java prototype



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)





As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.