B4J Question Method not matched

KentB

Member
Licensed User
Longtime User
what is wrong when trying to use a jar created with eclipse ?
package test1;
import javax.swing.*;
public final class testclass1 {

public static void ShowEclipseLibDialog(String[] arg) {
String st="Welcome to eclipse";
JOptionPane.showMessageDialog(null,st);
}
}
//this was exported to jar


Calling from B4J:
Sub Process_Globals
Private joEx As JavaObject
End Sub

Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
joEx.InitializeStatic("test1.testclass1")
End Sub

Sub btn1_Action
joEx.RunMethod("ShowEclipseLibDialog", Array("Message","Title"))
End Sub

Results in:
java.lang.RuntimeException: Method: ShowEclipseLibDialog not matched.
 

stevel05

Expert
Licensed User
Longtime User
It's saying that the variables you are passing are not in the format that the Method requires. The JavaObject Runmethod requires that you pass the parameters as an Array Object, which you are doing, but you have passed two strings instead of a string array. Try this:

B4X:
joEx.RunMethod("ShowEclipseLibDialog", Array(Array As String("Message","Title")))

Please enclose code blocks in [ CODE] [ /CODE] tags (without the spaces), it makes it much easier to read.
 
Last edited:
Upvote 0
Top