To compile a JavaScript file into java byte code invoke the following class
java org.mozilla.javascript.tools.jsc.Main my_script.js
java my_script
from http://www.rhino-tutorial.buss.hk/tutorials/compile-javascript-file
-
create a jar and add to
~/Library/Java/Extensions
:javac Jsc.java echo "Main-Class: Jsc" > manifest.txt jar -cmf manifest.txt jsc.jar Jsc.class mv jsc.jar ~/Library/Java/Extensions/
-
setup an alias:
alias jsc="java -jar ~/Library/Java/Extensions/jsc.jar $1"
compile javascript and run as java bytecode:
jsc my_script.js
java my_script