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;
}
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.