Other [SOLVED] Using an external jar.

Star-Dust

Expert
Licensed User
Longtime User
I have this source which works fine when compiling with jdk1.8.0_202 (the same one I use with B4J)

Java:
import com.WacomGSS.STU.*;
import com.WacomGSS.STU.Protocol.*;

public class simple2
{
  private void queryUsb()
  {
    com.WacomGSS.STU.UsbDevice[] usbDevices = UsbDevice.getUsbDevices();
    if (usbDevices != null && usbDevices.length > 0)
    {
      System.out.println("Num: "+usbDevices.length);    
    }
    else
    {
      System.out.println("no USB devices found");
    }
  }
  public static void main(String[] args)
  {
    simple2 program = new simple2();
    program.queryUsb();
  }
}

Reproducing a very similar code on b4j with java inline I get an error:
B4X:
#AdditionalJar: C:\Program Files (x86)\Wacom STU SDK\Java\jar\x64\wgssSTU.jar

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
End Sub

Sub Button1_Click
    Dim J As JavaObject = Me
    J.RunMethod("queryUsb2",Null) 
End Sub

#if JAVA
import com.WacomGSS.STU.*;
import com.WacomGSS.STU.Protocol.*;

public static void queryUsb2()
  {
    com.WacomGSS.STU.UsbDevice[] usbDevices = UsbDevice.getUsbDevices();
    if (usbDevices != null && usbDevices.length > 0)
    {
      System.out.println("Num: "+usbDevices.length);
    }
    else
    {
      System.out.println("no USB devices found");
    }
  }
#End If

This can be seen from the logs
 

Star-Dust

Expert
Licensed User
Longtime User
There is no .so file inside the jar.
The jar uses wgssSTU.dll which is bundled with the JAR.
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
...If it uses .dll may be need... jna... to download and import at project too ?
it uses jna and is already there in the B4J add-on libraries.
However the java code works it works correctly it's the b4j one that throws this error as if it can't find the class inside the JAR
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
SOLVED
It was necessary to put the parameters in the #VirtualMachineArgs ?
 
Upvote 0