Skip to main content
13-Aquamarine
February 20, 2013
Solved

How to call a public static void main(String[] args) method in an ACL function

  • February 20, 2013
  • 1 reply
  • 2073 views

I begin to do a java class, but I have a problem to call the "main" method in Arbortext.

My java class:

public class HelloObjIs

{

public static void main (String args[])

{

System.out.println("Hello");

}

}

How to call a public static void main(String[] args) method in an ACL function ?

    Best answer by SirkoRudolph

    Hi David,

    to call a static method from ACL you have to use the java_static() ACL function. In your case the call would be:

    ret = java_static("HelloObjIs","main",args);

    Now for the args you need to convert an ACL array to a Java array. Basically you would do the following in ACL:

    local myarr[];

    # ... put in values as needed or leave empty...

    myarr[1] = "something";

    # now convert to Java array

    local obj = java_array_from_acl(myarr,"[Ljava/lang/String;");

    # now call your static method with parameters

    ret = java_static("HelloObjIs","main",obj);

    Hope that helps.

    Kind regards

    Sirko

    1 reply

    5-Regular Member
    February 20, 2013

    Hi David,

    to call a static method from ACL you have to use the java_static() ACL function. In your case the call would be:

    ret = java_static("HelloObjIs","main",args);

    Now for the args you need to convert an ACL array to a Java array. Basically you would do the following in ACL:

    local myarr[];

    # ... put in values as needed or leave empty...

    myarr[1] = "something";

    # now convert to Java array

    local obj = java_array_from_acl(myarr,"[Ljava/lang/String;");

    # now call your static method with parameters

    ret = java_static("HelloObjIs","main",obj);

    Hope that helps.

    Kind regards

    Sirko

    dgopois13-AquamarineAuthor
    13-Aquamarine
    February 21, 2013

    Hi Sirko,

    Thank you for your help.

    Kind regards

    David