[SOLVED] JSR223 (JavaScript) development: How do I begin?

I apologize in advance for this generic and basic question. But I am lost and I don’t want to experiment on Eclipse installations for hours because with Eclipse being what it is this could get very cumbersome. :slight_smile:

Currently I’m using VSCode to write and maintain all my rules written in the Rules DSL. I’m familiar with Eclipse in general (I’m a Java developer by profession) but I have completely removed Eclipse from my openHAB workflow since the VSCode plugin got available. I have never used Eclipse to do actual openHAB (core / binding) development.

I am interested in migrating my rules to JSR223/JavaScript (because I’m very familiar with JavaScript and find the Rules DSL a bit limiting) and am wondering about how I should get started.

I have read:
Setting up an IDE for openHAB

Install (Scripted Rule Support) in IDE

but am still not 100% sure how to start and what to do. I assume I need Eclipse because it provides syntax checking etc. This might be obious to most of you but with VSCode around I’m not 100% sure. So when I install Eclipse via the Installer (I’m on Mac OS), what package do I choose? This is probably also very obvious to many but I’m really not sure. Maybe I don’t need any of those?


Once Eclipse is installed - do I just open a .js file and am good to go? I assume not because of the part of ther IDE documentation that tells me to add the following libs:


Where do I have to add those?

Just to be clear: I do not want to run a complete openHAB in Eclipse. I just want to use Eclipse as an editor for .js-files located in my /automation/jsr223 folder, hoping that it gives me some basic syntax checking and that the IDE knows which packages / methods are generally available and of what type method arguments are.

I already put a test .js-rule in /automation/jsr223 and messed around with it a bit (using VSCode). It works in general.

Thank you very much in advance! :slight_smile:


Unfortunately no, it will not. VS Code is actually better at doing syntax checking even without knowing the full Types. VS Code requires a language server to run in the background that provides it with Type information for auto-completion etc.

Because the distribution of scripts is not yet finalized, there is no language server yet for JSR223, only for Xtend based files (.things, .items, .rules).

1 Like

Then I’ll stick with VSCode for now. I thought there was more to JSR223 development. Thanks for the clarification! :+1:

Are there any tipps in terms of debugging you can give me? Is printing messages to the console the only way to go?

You may find ES5.1 limiting too! JDK9 has ES6 though, and it shouldn’t be too much loinger before it’s supported by OH.

Print to the console or log them. I setup a separate appender for JSR223, and tail that log, but you’ll get a lot out of setting org.openhab.core.automation to DEBUG too. Actually, that is currently org.eclipse.smarthome.core.automation for OH 2.4 and 2,5M1. There is some info and helper libraries here. And you’ll want to study this. Definitely don’t upgrade past ~S1512, until this is resolved. As David pointed out, the Eclipse IDE is not needed… VS Code works great. I mainly use Jython, but also have experience with using JS and Groovy with JSR223, so shout if you need some help!

Thanks a lot for compiling that information! :slight_smile: I’m following the post ESH fallout closely and have recently only upgraded to the last safe-ish milestone 2.5.0.M1. Thanks for the heads up concerning > 1512!

As long as I’m going to be able to use a library I’m a happy man! :smile:

Btw.: I am a fan of the Rules DSL and don’t necessarily think that it needs to go. Xtext features a relatively modern and sleek syntax without deviating too much from the usual suspects of the curly-languages. The with-then-end is great for readability and is intuitive. And we have functions, procedures and potentially many libraries. I feel that with a couple of tweaks here and there the Rules DSL could be fantastic. Which is a shame. Not complaining, though. Those guys do a great job. I’m just wondering if it is a good idea to throw away all that work now that it has reached maturity and get back to the old days of ignoring IDE errors. :wink: