Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you use Java to call the Rhino Javascript interpreter?

is there any example on using java method to call rhino-javascript function and return it back to java? The only example i found for rhino is only typing command on the rhino shell.

like image 618
cometta Avatar asked Feb 27 '10 06:02

cometta


People also ask

Can I call Java code from JavaScript?

JavaScript cannot call java method directly since it is on the server. You need a Java framework like JSP to call when a request is received from JavaScript.

Does Rhino use Java?

Rhino is a JavaScript engine written fully in Java and managed by the Mozilla Foundation as open source software. It is separate from the SpiderMonkey engine, which is also developed by Mozilla, but written in C++ and used in Mozilla Firefox.

Can I call Java class from JavaScript?

Calling Java from JavaScript. The Mozilla Rhino JavaScript interpreter bundled with Arbortext Editor provides a mechanism called LiveConnect that lets you use Java classes and methods from JavaScript.

What is the substitute of Rhino JavaScript engine in Java 8?

Until Java SE 7, JDKs shipped with a JavaScript scripting engine based on Mozilla Rhino. Java SE 8 will instead ship with a new engine called Oracle Nashorn, which is based on JSR 292 and invokedynamic .


1 Answers

Sure, here's the Rhino embedding tutorial. I've done this in the past and it works very well. You'll want to scroll down to this section.

like image 90
Jim Ferrans Avatar answered Oct 09 '22 16:10

Jim Ferrans