cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

How to call Java from JavasScript service ?

seanccc
17-Peridot

How to call Java from JavasScript service ?

Hi,

The engine that's used by ThingWorx JavaScript service is Rhino, it supports calling java directly as following : 

seanccc_0-1605149043198.png

. However , the similar usage doesn't work in ThingWorx JavaScript Service : 

seanccc_1-1605149103738.png

 

How to make it work in JavaScript service ? 

 

Regards,

Sean

4 REPLIES 4


Hello @seanccc,

 

Have you tried using with output string :

 

var pi = Math.PI;

result = Math.PI;

 

 

 

Hope it helps,

@Ciprian-Traian ,

 

Thank, you .  var pi = Math.PI;  works,  but I got the same error when doing further testing : 

 
 
 
 

============Rhino debugger=============

rhino native.png

 

 

============ThingWorx============

rhino interface.png

 

Regards,

Sean

Java primitive and classes are not exposed in ThingWorx Script Services.

 

You can create Java entities and services using the ThingWorx Extension SDK.

Tutorial : https://developer.thingworx.com/resources/guides/eclipse-plugin-thingworx-extension-development-tuto...

 

Regards.

seanccc
17-Peridot
(To:smainente)

@smainente ,

 

Do you know the reason why the java primitive classes are not exposed ?   it  bring lots of convenience for development.   

 

Regards,

Sean

Announcements