How this code works?

In Camunda Modeler

Service Task
http-connector

Under Output Parameter I have a variables as :

outputVar ,
Type=Script
Script Format = Javascript
Script Type=Inline Script

Whe I write a script as below in editor as below …

    var system = java.lang.System;
    system.out.println("It works!");

This code works.

As you see we are using Javascript … Javascript does not have system.out.println …right ? So this script should show error .

How this code works then ?

Hi @cofactor,

the Javascript code is executed in the nashorn runtime in the Java virtual machine. Here you have access to java classes from your javascript code. Have a look at the orcale docs for further information: https://docs.oracle.com/javase/8/docs/technotes/guides/scripting/nashorn/toc.html

Hope this helps, Ingo

okay…looks good.

can I import any java classes from java 8 API in this javascript code ? or only limited java classes can be used in javascript ?

I haven’t reached the borders right now. Maybe the docs help you further…

1 Like