Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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).

share|improve this question
up vote 3 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"
}
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .