xiaoyao Active Member Licensed User Longtime User Mar 22, 2015 #1 public static void main(String[] args) throws Exception { // } how can i call a method from b4a to jar? I ADD THIS JAR BY : #AdditionalJar: DemoNoMainSub RunMethodjo("init",Array(AppId,AppSecret,Model)) HOW TO DO LIKE THIS Private Sub GetManager As JavaObject Dim jo As JavaObject Return jo.InitializeStatic("COM.ABC.DD").RunMethod("MAIN", Array(GetContext)) End Sub
public static void main(String[] args) throws Exception { // } how can i call a method from b4a to jar? I ADD THIS JAR BY : #AdditionalJar: DemoNoMainSub RunMethodjo("init",Array(AppId,AppSecret,Model)) HOW TO DO LIKE THIS Private Sub GetManager As JavaObject Dim jo As JavaObject Return jo.InitializeStatic("COM.ABC.DD").RunMethod("MAIN", Array(GetContext)) End Sub
Erel B4X founder Staff member Licensed User Longtime User Mar 22, 2015 #2 The method name is main not MAIN. Upvote 0
xiaoyao Active Member Licensed User Longtime User Mar 22, 2015 #3 i also try with main,but can't do ,can you try? class1=ClassLoader.getSystemClassLoader().loadClass("com.sun.tools.javac.Main"); Class[] argTypes = new Class[] { String[].class }; String[] mainArgs = {File1}; Method method=class1.getDeclaredMethod("main",argTypes); method.invoke(class1.newInstance(),(Object)mainArgs); in windows ,i add tools.jar(jdk file path),it can Compile abc.java to abc.class ,only one args,can it doing on ANDROIS? Upvote 0
i also try with main,but can't do ,can you try? class1=ClassLoader.getSystemClassLoader().loadClass("com.sun.tools.javac.Main"); Class[] argTypes = new Class[] { String[].class }; String[] mainArgs = {File1}; Method method=class1.getDeclaredMethod("main",argTypes); method.invoke(class1.newInstance(),(Object)mainArgs); in windows ,i add tools.jar(jdk file path),it can Compile abc.java to abc.class ,only one args,can it doing on ANDROIS?
Erel B4X founder Staff member Licensed User Longtime User Mar 23, 2015 #4 I'm sorry but I don't understand what you are trying to do. tools.jar is not an Android library. It will not work from an Android app. Upvote 0
I'm sorry but I don't understand what you are trying to do. tools.jar is not an Android library. It will not work from an Android app.