I want to excute javascript file without a browser. I found Mozila Rhino, but I wonder that how can I config sublime text or another text editor run my .js file directly (i.e without run command line).

link|improve this question
feedback

1 Answer

up vote 1 down vote accepted

Linux solution:

Create a bash file: /usr/sbin/rhino

#!/bin/sh
java -cp /opt/rhino1_7R3/js.jar:. org.mozilla.javascript.tools.shell.Main "$@"

Note: /opt/rhino1_7R3 is where I installed my rhino — you can extract it where you please.

On Sublime, go to Tools » Build System » New Build System. Paste the following and save the file.

{
    "cmd": ["rhino", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.javascript"
}
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.