Android Question how to call sub from java to b4a sub


Licensed User
i creat jar lib by java,how to call a sub from java code to b4a sub?
like this
i creat a java file ""

package com.example;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;
//import anywheresoftware.b4a.BA.*;
//@DependsOn(values={"some java library "})
public class FirstLib {
public int add(int x, int y) {
return x + y;
public int add2(int x, int y) {
return x + y;

if i change this
public int add2(int x, int y) {
int c=0;
return c;

in b4a ,have a sub
sub sub1(x as int ,y as int)
return x+y
end sub

c=b4a.main.sub1(x,y);i think it's wrong,how can i write the code?