开发者

Does Java 6 include a program that can run javax.script (Rhino JS) files?

开发者 https://www.devze.com 2023-01-08 02:55 出处:网络
I found that Java 6 includes Rhino JS (except for one or two minor pieces), as javax.script.Pretty cool!

I found that Java 6 includes Rhino JS (except for one or two minor pieces), as javax.script. Pretty cool!

Does a Java 6 install (JRE or JDK, either) contain a binary that I can simply point to a .js file to run? (I think it would be great to be able to provide source code for others to read and run, without comp开发者_高级运维ilation, and require only that Java be installed.) Or do I have to build the little 8-line program in the docs?


Yes, There's jrunscript


There's a binary included in the JDK called jrunscript:

wookie@hoth:/usr/local/java/bin$ ./jrunscript 
js> println("This is hello from test.js");
This is hello from test.js


On Debian based systems, you can install the Rhino package and access a console application called js. From there, you can have all your js files begin with:

#/usr/bin/js

and set the script to executable to run them directly.

0

精彩评论

暂无评论...
验证码 换一张
取 消