There are already three other bundles more or less available allowing you to use java in OpenHAB, so why another one ?
First, many thanks to them, especially @J-N-K for the SmartHome/J implementation, from which I took a good share of code. I kept author names in some classes to reflect that. The 3 other bundles are:
I decided to do another one, mainly for these two requirements :
a bundle available on the main OpenHAB marketplace, and maybe merged as an official add-on in some time
fully compatible JSR223
So I started by proposing small features to @weberjn bundle. But I didn’t stop at “small” and had other ideas, which was going against its preference of keeping the bundle simple. So I forked for myself. Then I learned about the SmartHome/J bundle (I wasn’t aware of it before), and took some code and ideas from it (but with a very different compiling architecture)
Then, I kept piling new features:
a cache for very fast execution and reuse of instance (allowing sharing value between executions)
a very clear separation between the way you can write your Java scripts (no dependencies at all, plain java class), the bundle, and the helper library which is “just” a library that you could have written yourself and that can evolve independently.
a ‘no boilerplate’ option for one liner script
many quality of life improvement (a smart injection of openHAB values, some effort for flexibility to propose different coding ways, some default values here and there to shorten lengthiness or complexity of code, etc.)
and other features… (See documentation)
Now the base code is waaayyy different from all of those, and thus, a new bundle. I’m not sure if it is better (probably not, and this bundle won’t have all the features the other ones can have, I think for example JRule has many helper functions), but the reverse is certainly true : it has its own strong arguments that others don’t have.
If this bundle doesn’t meet a public, I will of course remove it from the marketplace, as I don’t want to add useless confusion to this already many-bundle situation.
Nice. Just had a brief look at the code (I personally switched to JavaScript). If you want to open a PR in openhab-addons, Please ping me and I’ll try to assist with the review process.