B4J Question jo.RunMethod error

Shivito1

Active Member
Licensed User
Error:
B4X:
Waiting for debugger to connect...
Program started.
Type Network Path: example(\\Server\SharedFolder)
Error occurred on line: 61 (Main)
java.lang.IllegalArgumentException: object is not an instance of declaring class
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:131)
    at b4j.example.main._listview1_mouseclicked(main.java:188)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:614)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:228)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:93)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:77)
    at anywheresoftware.b4j.objects.NodeWrapper$1.handle(NodeWrapper.java:90)
    at anywheresoftware.b4j.objects.NodeWrapper$1.handle(NodeWrapper.java:1)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
    at javafx.event.Event.fireEvent(Event.java:198)
    at javafx.scene.Scene$ClickGenerator.postProcess(Scene.java:3470)
    at javafx.scene.Scene$ClickGenerator.access$8100(Scene.java:3398)
    at javafx.scene.Scene$MouseHandler.process(Scene.java:3766)
    at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)

Code:

B4X:
Sub ListView1_MouseClicked (EventData As MouseEvent)
    If EventData.ClickCount = 2 Then
        Dim x As String
        x = (ListView1.SelectedItem)
        Log(x)
        #if java
    public void foo() {
        try {
        @SuppressWarnings("unused")
        Process p = new ProcessBuilder("explorer.exe", "/select,C:\\directory\\selectedFile").start();
        } catch (Exception name) {
            System.out.print("does not = 1");
}}
        #End If
        Dim NativeMe As JavaObject = Me
        NativeMe.RunMethod("foo", Null)
    End If
End Sub
 

Daestrum

Expert
Licensed User
Longtime User
The error was caused by the keyword 'static' missing.
ie
B4X:
public void foo()
should be
B4X:
public static void foo()
 
Upvote 0

Shivito1

Active Member
Licensed User
The error was caused by the keyword 'static' missing.
ie
B4X:
public void foo()
should be
B4X:
public static void foo()
WOOOOt yes that worked my goodness thank you so much
thank you thank you thank you.
I ran in to another problem and was facing this issue again. came here and say that you solved it. Thanks a bunch Daestrum!!!
 
Upvote 0
Top