B4J Question Inline Code Error - object is not an instance of declaring class

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,

I am trying to use the inline code but when I try to return a value it causes an error.

Anyone know why it's showing this error ?

I am using:
B4J Version 9.80
Java 14
Non-UI app

B4X:
'Non-UI application (console / server application)
#Region Project Attributes
    #CommandLineArgs:
    #MergeLibraries: True
#End Region

Sub Process_Globals

End Sub

Sub AppStart (Args() As String)
    
    Dim jo As JavaObject = Me
    
    Dim s As String = jo.RunMethod("FirstMethod", Null)
    Log(s)
    
    StartMessageLoop
End Sub

#If JAVA
public String FirstMethod() {
   return "Hello World!";
}
#End If

Error that it displays is:
 

Daestrum

Expert
Licensed User
Longtime User
( note the static in the method signature )

B4X:
#If JAVA
public static String FirstMethod() {
   return "Hello World!";
}
#End If
 
Last edited:
Upvote 1
Cookies are required to use this site. You must accept them to continue using the site. Learn more…