is possible to use any methods from external library of JavaScript in OH? Eg.
const http = require('http');
or is possible to use Java in rules without installation add component like “JRule - openHAB Rules using Java” (btw: still in beta), OH is coded in Java, so is it possible to use Java in any way in rule?
Yes with some warnings. The JS Scripting add-on provides a node.js like environment but it’s not fully compatible with the full node.js environment. Most libraries should work but any that depend on the event loop or stuff like that will likely not work.
You must first install the library using npm to $OH_CONF/automation/js (e.g. cd $OH_CONF/automation/js && npm install openhab_rules_tools). The bottom of the docs for the JS Scripting add-on has more details about installing and writing your own libraries.
Ues, you can import and use Java classes into your JS Scripting rule. A bunch of OH related classes (see JSR223 Scripting | openHAB) can be imported using const runtime = require("@runtime"); and then accessed using, for example, runtime.OnOffType.ON.
Any other Java class from the JRE and from openHAB itself can be imported using const HTTP = Java.type("java.net.http.HttpClient");. I don’t know if there is a way to import and use a third party Java library though.
Note, when working with Java Classes you must be aware of types. For example, a Java List<?> is not the same as a JS Array and cannot be used interchangable. If you have a Java Object or class, you must only use Java Objects with it except for ZonedDateTime (I think), primitives, and Strings.
jRuby has a similar mechanism I beleive and supports Ruby gems. Rules DSL can use import to import any of the core and openHAB Java classes also. Groovy is mostly working with Java as I understand it.