How can you code an openhab script with Normal Java

Is it possible to code a normal Java openHab script? So that you can put a .java file into the script folder.

Thank you.

No that is not supported.

But with Xten i get an Error every time. I installed Xten on Eclipse and when i create an exsample Project it shows me thousonds of import and syntax errors

Then you are not writing Rules. Or if you are writing Rules, you are not following the documentation for how to write Rules.


Reviewing How to get started (there is no step-by-step tutorial) would be a good idea as there are lots of good resources there.

Some important quotes from the Rules docs:

The openHAB VS Code Extension offers support for rules building. It includes syntax checks and coloring, validation with error markers, content assist (Ctrl+Space) incl. templates etc. This makes the creation of rules very easy!

The rule syntax is based on Xbase and as a result it is sharing many details with Xtend, which is built on top of Xbase as well. As a result, we will often point to the Xtend documentation for details.

Based on Xbase and sharing commonality with Xtext does not mean is eaxactly Xtext. The language is a Domain Specific Language unique to openHAB. The only IDE support is VSCode with the openHAB Extension. Not Eclipse.

Rules DSL is not the only option. Search the forum and the docs for “Python”, “Jython”, “JavaScript”, “Scripted Automation”, or “JSR223” and you will find tons of resources.

I wanted to code a server socket script is this possible ?

You would need to code a binding for that. It’s not really appropriate to code something like that in Rules, no matter the language. You might be able to code it using one of the Scripted Automation languages, but like I said, that’s not really an appropriate job for Rules.

Isnt there such binding system you can install now?

Sorry but you need to tell what you intend to do and not answer with one line answers so we need to guess what you want. That way we cannot help you.