So, I have built a jar file named PrintPageReportWrapper.jar that I can execute from a command line with java -jar PrintPageReportWrapper.jar. Unfortunately, I have never had to go beyond this point in my java development other than deploying the jar file to desktop computers.
I am now trying to run one of the internal methods from B4J and can't seem to get past some java exceptions. Here are my B4X code attempts and the results. I have tried other combinations but I think one of these should work.
Can someone tell me what I am doing wrong (either in the java program and/or B4J)?
Of course I started by copying my jar file to the ... B4X\additionallibraries\B4X folder and adding the following to main:
#AdditionalJar: PrintPageReportWrapper
Not sure how to properly insert code in these posts ...
First approach:
{code}
Dim jo As JavaObject
jo = jo.InitializeStatic("net.nmcollector.printpagereportwrapper.PrintPageReportWrapper")
jo.RunMethod("openPrintPageReport", Array(sqlConnectionString, MainPage.selectedCollectionId, MainPage.selectedItemId, MainPage.selectedTab, MainPage.tabLabelsList.Get(MainPage.selectedTab) & ": " & B4XFloatTextFieldItemListValue.text))
{/code}
Stack Trace:
Second approach:
{code}
Dim jo As JavaObject
jo = jo.InitializeStatic("net.nmcollector.printpagereportwrapper.PrintPageReportWrapper")
jo = jo.GetFieldJO("INSTANCE")
jo.RunMethod("openPrintPageReport", Array(sqlConnectionString, MainPage.selectedCollectionId, MainPage.selectedItemId, MainPage.selectedTab, MainPage.tabLabelsList.Get(MainPage.selectedTab) & ": " & B4XFloatTextFieldItemListValue.text))
{/code}
Stack Trace:
Here is a peak at my class definition:
{code}
public class PrintPageReportWrapper {
public static final PrintPageReportWrapper INSTANCE = new PrintPageReportWrapper();
private PrintPageReportWrapper() {}
{/code}
Here is a link to a zip file with my entire IntelliJ project for the java program including source code and the generated jar file: https://nmcollectorsoftware.us/downloads/PrintPageReportWrapper.zip
Thanks!
I am now trying to run one of the internal methods from B4J and can't seem to get past some java exceptions. Here are my B4X code attempts and the results. I have tried other combinations but I think one of these should work.
Can someone tell me what I am doing wrong (either in the java program and/or B4J)?
Of course I started by copying my jar file to the ... B4X\additionallibraries\B4X folder and adding the following to main:
#AdditionalJar: PrintPageReportWrapper
Not sure how to properly insert code in these posts ...
First approach:
{code}
Dim jo As JavaObject
jo = jo.InitializeStatic("net.nmcollector.printpagereportwrapper.PrintPageReportWrapper")
jo.RunMethod("openPrintPageReport", Array(sqlConnectionString, MainPage.selectedCollectionId, MainPage.selectedItemId, MainPage.selectedTab, MainPage.tabLabelsList.Get(MainPage.selectedTab) & ": " & B4XFloatTextFieldItemListValue.text))
{/code}
Stack Trace:
Error occurred on line: 389 (B4XFloatTextField)
java.lang.RuntimeException: Method: openPrintPageReport not matched.
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:130)
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.runVoidMethod(Shell.java:676)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:240)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at jdk.internal.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
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:108)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA$1.run(BA.java:233)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
Second approach:
{code}
Dim jo As JavaObject
jo = jo.InitializeStatic("net.nmcollector.printpagereportwrapper.PrintPageReportWrapper")
jo = jo.GetFieldJO("INSTANCE")
jo.RunMethod("openPrintPageReport", Array(sqlConnectionString, MainPage.selectedCollectionId, MainPage.selectedItemId, MainPage.selectedTab, MainPage.tabLabelsList.Get(MainPage.selectedTab) & ": " & B4XFloatTextFieldItemListValue.text))
{/code}
Stack Trace:
java.lang.RuntimeException: Field: INSTANCE not found in: net.nmcollector.printpagereportwrapper.PrintPageReportWrapper
at anywheresoftware.b4j.object.JavaObject$FieldCache.getField(JavaObject.java:307)
at anywheresoftware.b4j.object.JavaObject.GetField(JavaObject.java:182)
at anywheresoftware.b4j.object.JavaObject.GetFieldJO(JavaObject.java:189)
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:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at jdk.internal.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
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:108)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA$1.run(BA.java:233)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)
Here is a peak at my class definition:
{code}
public class PrintPageReportWrapper {
public static final PrintPageReportWrapper INSTANCE = new PrintPageReportWrapper();
private PrintPageReportWrapper() {}
{/code}
Here is a link to a zip file with my entire IntelliJ project for the java program including source code and the generated jar file: https://nmcollectorsoftware.us/downloads/PrintPageReportWrapper.zip
Thanks!