#if java
public class thisTest{
public thisTest(){
}
}
#End If
Now I want to call and use this class with javaobject library:
B4X:
Dim j2 As JavaObject=Me
j2.InitializeNewInstance(Application.PackageName & "." & "thistest",Array(Null))
But I get the following error:
java.lang.ClassNotFoundException: b4a$example$thistest
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:453)
at anywheresoftware.b4j.object.JavaObject.getCorrectClassName(JavaObject.java:274)
Sub Activity_Create(FirstTime As Boolean)
jo.InitializeNewInstance(Application.PackageName & ".main$thisTest",Array(Null))
End Sub
#if Java
public class thisTest{
public thisTest(){
BA.Log("here");
}
}
#End If
runs for me (b4a 12.80, android 12). if i make the class static (which is what i normally would have done), i get a constructor not found error. i switched back and forth a number of times to make sure my eyes weren't up to their usual tricks. can you check it out?
The next versions of B4A (4.30) and B4J (2.80) will allow you to embed Java code inside your B4X code. B4i supports similar feature with Objective C. The purpose of this feature is to make it easier to access third party SDKs and also to allow developers to add existing Java code snippets to...
www.b4x.com
Just use static methods in java, not classes. It´s quite easy to call them.
Sub Activity_Create(FirstTime As Boolean)
jo.InitializeNewInstance(Application.PackageName & ".main$thisTest",Array(Null))
End Sub
#if Java
public class thisTest{
public thisTest(){
BA.Log("here");
}
}
#End If
runs for me (b4a 12.80, android 12). if i make the class static (which is what i normally would have done), i get a constructor not found error. i switched back and forth a number of times to make sure my eyes weren't up to their usual tricks. can you check it out?
public static class thisTest{
public thisTest(){}
public void say(){
BA.Log("here");
}
}
And this is the code in B4A (B4XPages)
B4X:
Private Sub Button1_Click
Dim myClass As JavaObject
myClass.InitializeNewInstance("b4a.example.main$thisTest",Null)
myClass.RunMethod("say",Null)
xui.MsgboxAsync("Hello world!", "B4X")
End Sub
thank you @drgottjr and @Daestrum
As you mentioned, the thistest class is a class of the main class, and this problem was solved by inserting main before the class name.
Thanks
#if java
public class thisTest{
public thisTest(){
}
}
#End If
Now I want to call and use this class with javaobject library:
B4X:
Dim j2 As JavaObject=Me
j2.InitializeNewInstance(Application.PackageName & "." & "[URL='https://berufshaftpflichtversicherungen-heute.de/wellness/']t[/URL]histest",Array(Null))