2

I'm trying to call an external Java function from Haxe. How can I call a Java function that I've written from Haxe?

Java code:

public class ExternalClass{

    public static String myFunction(){ //this will be invoked from Haxe
        return "External Java function";
    }

}

Haxe main class:

class Main 
{
    public static function main() 
    {
        trace(myFunction()); //how can I properly access this Java method?
    }
}

Haxe extern class:

extern class Test
{
    public static function myFunction():String;
}
4

1 Answer 1

2
class Main 
{
    public static function main() 
    {
        trace(ExternalClass.myFunction()); //how can I properly access this Java method?
    }
}

extern class ExternalClass
{
    public static function myFunction():String;
}

Your external class should have the same name that your native java class.

Then you must call your function as a classic static one, prepending the class name to the function name.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.