Reputation: 4468
I've been reading about Rhino as a useful way to implement JavaScript inside my Java code.
After reading for a while, searching in google and here, I couldn't find a real reason for which I would use JavaScript inside Java.
Could you point some real world advantages you find on using Rhino for a regular Java application?
Upvotes: 15
Views: 4505
Reputation: 181
If you considering to .Net also, I suggests to get along with Rhino.
Besides Java enviroments, rhino is one of the best performance interpreter on .NET environment (using IKVM). On the other hands, nashorn is very slow on .net.
Porting your own Rhino project to .NET is not so difficult.
Upvotes: 0
Reputation: 719
The benefit of embedding a script language like javascript into your software is that you can offer others a way to write plugins for your software without giving the source code away.
A reason to write the whole app in another language is that you are able to write an app for a company which deploys it in their Java EE environment without having to learn Java.
Upvotes: 6
Reputation: 725
We use JS (via Rhino) for a DSL in one of our products. It isn't a great DSL, but that is a fault of how we use JS, rather than Rhino.
Upvotes: 4
Reputation: 586
Upvotes: 11
Reputation: 206876
Note that since Java 6, the scripting API is in the standard Java library - see the documentation of the package javax.script
. The API in javax.script
is an adapted version of Rhino. The scripting API supports not only JavaScript, but many other scripting languages.
See Java Scripting Programmer's Guide
The front page there mentions some reasons you might want to use scripting:
- Application extension/customization: You can "externalize" parts of your application - like configuration scripts, business logic/rules and math expressions for financial applications.
- "Command line" shells for applications -for debugging, runtime/deploy time configuration etc. Most applications have a web-based GUI configuaration tool these days. But sysadmins/deployers frequently prefer command line tools. Instead of inventing ad-hoc scripting language for that purpose, a "standard" scripting language can be used.
An example: You can script Oracle Weblogic using Python scripts, for example to configure your application server domain, to start or stop the server and to do other administration tasks.
Upvotes: 15