How to import SikuliX to Javascript or NodeJS script using GraalVM?

Asked by zhenya

Hello!
In "Using JavaScript" section of documentation it is mentioned that Javascript scripting for SikuliX (sikulixapi.jar) using GraalVM is already available .
But currently I'm struggling to figure out how to import sikulix to my script (which I would write on pure JS or on NodeJS).

Previously I was using Jython and was just as simple as this:

import org.sikuli.script.SikulixForJython
from sikuli import *

How to do the same thing when scripting on JS or NodeJS and using GraalVM?

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
zhenya (zhenya.kozhevnikov) said :
#1

Also short clarification here - earlier I found a solution to this isssue - https://answers.launchpad.net/sikuli/+question/692158
therefore I'm sure that environment variable is set up correctly. Tested this by writing java script with given import:

import org.sikuli.script.App;

Everything works as expected.

So this current question is only about how to do "import" part from JS or NodeJS.

Revision history for this message
RaiMan (raimund-hocke) said :
#2

I am sorry, but currently I handle JavaScript support with low to no priority.

I have changed the docs accordingly, so you can try with JavaScript in the SikuliX IDE up to Java 14 (Java 15 will come without Nashorn).

... and GraalVM looks promising, but is also not one of my current priorites.

Revision history for this message
zhenya (zhenya.kozhevnikov) said :
#3

I see. Just one more question then - is it possible to use node.js in SikuliX IDE?

Revision history for this message
RaiMan (raimund-hocke) said :
#4

SikuliX IDE is an eco-system, that allows to create/edit and run scripts mainly written in Python language (Ruby is also supported to some extent and JavaScript is useable as long as you use a Java version, that has the Nashorn engine).
SikuliX IDE focuses on the support of the specific SikuliX features and lacks most of the features of a mature IDE like auto-complete, debugging, ...

Node.js is a runtime environment for programs written in JavaScript and as such comparable to the Java based Python interpreter Jython, that we use with SikuliX.

Since currently SikuliX is completely Java based, the usage of node.js with SikuliX is not possible and does not really make sense.

The only thing that might make sense in very special cases: You have some app that runs on node.js and you want to run that from inside a SikuliX script, you might issue the node.js run in a separate subprocess.

Can you help with this problem?

Provide an answer of your own, or ask zhenya for more information if necessary.

To post a message you must log in.