Scripting for Java
JSR223 "describe mechanisms allowing scripting language programs to access information developed in the Java Platform and allowing scripting language pages to be used in Java Server-side Applications."
This defines a framework to allow scripting language programs to access information developed in the Java platform. We currently plan to integrate this into Mustang for b40. Aside from the framework, we will also include a JavaScript engine based on the Mozilla Rhino implementation. Later, we hope to include a scripting shell that is script language independent. This will be a very cool way to create a prototype, do some exploratory coding, and learn new APIs.
The latest release of Mustang has already included this feature. You can check out the latest release of JavaSE to have a try.
There are 3 blog entries to talk about this:
Example: using JavaScript in Java
Simple JavaScripting from Java
Scripting Support in Mustang - An Example You Can Try
Then why adding scripting languages to Java?
two ways of using Java aware scripting languages: exploratory programming and testing, and user level scripting of applications. - Scripting Languages For Java
What interested me most is that it is a framework but not a simple implementation. So, any other scripting languages (such as PHP, Ruby … )can be added to Java if someone develop a module implementation following the framework standard. So, it’s "An architecture of participation".
- //import package
- import javax.script.*;
- public class Main {
- public static void main(String[] args) {
- try {
- // create a script engine manager
- ScriptEngineManager manager = new ScriptEngineManager();
- // create script engine for JavaScript
- ScriptEngine jsengine = manager.getEngineByName("js");
- // evaluate JavaScript code from String
- jsengine.eval("print('hello world')");
- } catch (ScriptException se) {
- // Handle script exception here..
- // FIXME: do a better job here!
- se.printStackTrace();
- }
- }
- }
Popularity: 24%
Related entries:
- No Related Posts

August 12th, 2005 at 9:37 am
我认为应用开发脚本语言会慢慢的取得一定的市场分额的.
就象互联网动态页面最开始时候是使用C/C++写的CGI,慢慢的被perl写的CGI所取带一样,
而C/C++也还会继续在他的优势地带发挥作用(从国内的应用也能看出,如QQ公司使用FASTCGI(C/C++)等技术进行开发),但是他的大部分市场分额被perl/php等取代.
现在python的流行也说明一个问题,也就是python取慢慢取得一些窗口应用程序的市场分额.目前还没有很好的IDE.能进行快速和企业级的开发,但是我觉得确实是一个趋势.
而这些东西都属于开源,而开源的资源分散,所以存在一个资源整合的问题.
目前perl6的parrot正在做这些整合,但是路还很长.