cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

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

dgopois
12-Amethyst

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

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 ?

1 ACCEPTED SOLUTION

Accepted Solutions
SirkoRudolph
5-Regular Member
(To:dgopois)

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

View solution in original post

2 REPLIES 2
SirkoRudolph
5-Regular Member
(To:dgopois)

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

Hi Sirko,

Thank you for your help.

Kind regards

David

Top Tags