Hello,
some time ago I wanted to use Yjs in Java but I could not find any projects with Java bindings. Remembering what I learned in university some 7 or 8 years ago about JNI and (way more comfortable) JNA I looked into it.
While JNI may be a more performant way to access native code from Java, with JNA being said to be up to 13 times slower, I still decided to use JNA over JNI.
Using JNI is very, very … very time consuming - time I simply don’t have. Yrs is quite a big library.
For me, it was not a choice between JNA and JNI but rather between having Java bindings and not having Java bindings.
And there I went.
You already supply a C header for the library, so “all I had to do” was:
- generate dynamic libraries for windows and linux using the yffi project (and hopefully mac soon)
- find a generator for JNA Bindings because I was NOT going to do this by hand! (I ended up using JNAerator)
- write a wrapper layer around the bindings so it is more comfortable for Java users
and then see what fails.
After fiddling around with this for a few more hours and making stuff work I began to like the idea of it. On the weekends and sometimes after work when I wasn’t too tired of writing Java all day already, I continued to work on it.
I’m still not finished or even close to being finished, but there is progress!
Having said all this, I now realize I probably overshared, lol.
Anyway, here is the link to the repo: GitHub - segreeeen/Yrs4J: Java Bindings for Yrs
I named it Yrs4J in the “funny” tradition of calling everything that is wrapped or ported to Java “4J”. I also published some maven packages to my nexus so it can be used easily.
I hope you like it.
If there are other Java people here who would like to contribute - please do!!
Best wishes!
SeGreeeen