Hello,
sorry, I didn't find any answer searching on the forum till now.
I wish to try to call a Java class/function from B4J (not B4A) and I've tried this simple example:
I've included the JavaObjext library, but I continue to get this error when I start the application.
I don't understand what I missed.
Can someone help me ?
Thank you.
sorry, I didn't find any answer searching on the forum till now.
I wish to try to call a Java class/function from B4J (not B4A) and I've tried this simple example:
B4X:
'Non-UI application (console / server application)
#Region Project Attributes
#CommandLineArgs:
#MergeLibraries: True
#End Region
Sub Process_Globals
Private NativeMe As JavaObject
End Sub
Sub AppStart (Args() As String)
NativeMe.InitializeContext
Dim s As String = NativeMe.RunMethod("FirstMethod", Null)
Log(s)
End Sub
#If JAVA
public String FirstMethod() {
return "Hello World!";
}
#End if
I've included the JavaObjext library, but I continue to get this error when I start the application.
B4X:
Waiting for debugger to connect...
Program started.
Error occurred on line: 12 (Main)
java.lang.NoSuchFieldException: sharedProcessBA
at java.base/java.lang.Class.getDeclaredField(Class.java:2412)
at anywheresoftware.b4j.object.JavaObject.InitializeContext(JavaObject.java:57)
at b4j.example.main._appstart(main.java:61)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
at b4j.example.main.main(main.java:29)
Program terminated (StartMessageLoop was not called).
I don't understand what I missed.
Can someone help me ?
Thank you.
Last edited: