B4J Question Using Java in B4J? - Possible job posting?

rspitzer

Active Member
I do a lot of motor control interfacing in my embedded applications. I switched from Visual Basic.net to B4J primarily for the cross platform ease of use and the the rather easy way you can generate HMI's for operator usage. When I was using the .Net platform, I was able to use interface boards from Phidgets Inc. in Canada. They make a number of high speed encoder boards (as well as other products). They have API's for most languages and OS platforms. They have a Java api etc.. To keep this short, is there a way I can use their Java API in B4J (If i know the proper calls) and if so, can someone point me a proper dirOr should I post a job for someone that can wrap the Phidget Java API into a B4x library for me and anyone else to use. ???
 

DonManfred

Expert
Licensed User
Longtime User
Post a link to the documentation and SDK.
Maybe you dont need it at all if they provide a REST Api.
 
Upvote 0

rspitzer

Active Member
Thank you for your answers, though I am clearly in the deep end of the pool.

For Don Manfred - this is a link below:

For Erel:
I took a look at your tutorial about Inline Java and used your Inline Java example as an experiment, the Java code just basically sees if there's a connection to the Phidget Encoder board and returns True or gives an error. The code actually compiled with no errors, but I do get a runtime error, that of course relates to how the code is actually setup I am sure. I do not understand as of yet how to setup the return I assume.

Phidget encoder test - inline Java:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private NativeMe As JavaObject
End Sub

#AdditionalJar: phidget22.jar

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.Show
    NativeMe = Me
    Dim s As String = NativeMe.RunMethod("main",Null)
    Log(s)
End Sub

#If JAVA

import com.phidget22.*;

    public void main() {
        try {
            Encoder ch = new Encoder();
            ch.open(Phidget.DEFAULT_TIMEOUT);

            boolean Enabled = ch.getEnabled();

            ch.close();
            
        } catch (PhidgetException ex) {
            System.out.println("Failure: " + ex);
        }
    }

#End If

The runtime error I get is: (I just posted the first lines, thought that would be enough).

Program started.
Error occurred on line: 17 (Main)
java.lang.IllegalArgumentException: object is not an instance of declaring class

Line 17 is of course the runmethod call, it just tells me I am really in the deep end of the pool.
I have a feeling, that I should just post a job offer for someone to I guess create a library or wrapper (I am not sure of the terminology) out of the Phidget22.jar file???
 
Upvote 0

tchart

Well-Known Member
Licensed User
Longtime User
@rspitzer probably not a good idea to call your java function "main" as Main is already defined by B4J

JavaObject is handy for call small methods in native Java Libraries but if your library is large/complex then a wrapper may be the way to go. A quick look at the Phidget website tells suggests to me its event based (eg phidegt is in motion) so a wrapper is a good idea.
 
Upvote 0

rspitzer

Active Member
Thanks for the suggestion on the main issue.
I have decided to go ahead and post a job offer to have someone wrap the Phidget22.jar if possible to use in B4X (And hopefully not be too expensive). If this can be done, I will like it to be a public wrapper for all to use and a posted library for B4X with the credit going to the person who can do this. I will also approach Phidgets Inc., to see if they would post a mention of the wrapper on their website along with their support for Android Studio, Eclipse, Visual Studio etc., this may hopefully drum up some more interest in the B4X platform.
 
Upvote 0
Top