B4J Question pi4j question

madru

Active Member
Licensed User
Longtime User
Hi, has somebody played with pi4j recently ?

B4X:
Sub GetBus(BusNumber As Int) As JavaObject
    Dim factory As JavaObject
    Return factory.InitializeStatic("com.pi4j.io.i2c.I2CFactory").RunMethodJO("getInstance", Array As Object(BusNumber))
End Sub

returns
B4X:
java.lang.ClassNotFoundException: com.pi4jj$io$i2c$I2CFactory
 

madru

Active Member
Licensed User
Longtime User
that's what I get....

B4X:
Sub AppStart (Args() As String)
    bus = i2c.GetBus(1)
    Log(bus)
End Sub

B4X:
Sub GetBus(BusNumber As Int) As JavaObject
 
    Dim factory As JavaObject
    Return factory.InitializeStatic("com.pi4j.io.i2c.I2CFactory").RunMethodJO("getInstance", Array As Object(BusNumber))
 
End Sub

B4X:
Waiting for debugger to connect...
Program started.
Error occurred on line: 8 (i2c)
java.lang.ClassNotFoundException: com.pi4j$io$i2c$I2CFactory
    at anywheresoftware.b4j.object.JavaObject.getCorrectClassName(JavaObject.java:289)
    at anywheresoftware.b4j.object.JavaObject.InitializeStatic(JavaObject.java:75)
    at b4j.example.i2c._getbus(i2c.java:39)
    at b4j.example.main._appstart(main.java:74)
    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:632)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja
va:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
    at b4j.example.main.main(main.java:29)
Program terminated (StartMessageLoop was not called).
 
Upvote 0

roberto64

Active Member
Licensed User
Longtime User
Hello, i have been trying libreia PI4J for days, but after many attempts and many tests i discover that if i use rasberry PI4 java ver.11.0.7 already installed it works, i still have to try java ver.14.0, in versions PI4J 1.2 and 1.3 give errors, I downloaded the ver.2 PI4j and I put only "pi4j-core.jar" and I remove the PI4J library the problem no longer exists, in reference to the code "B4J_LCD_BigNumber" all right up to row 56 of the lcd class with i2c call in writing it gives me this error, I have been trying for days to write in my 1602A LCD which uses "0x27" as a device, but nothing.
1 question qule java version and compatible with PI4J.
2) someone operated the LCD of the Freenova LCD 1602A kit.
3) Any help?
regards
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…