Skip to main content


RunJS requires Linux/macOS and Java 8 or above

Install

curl -sSL https://runjs.cc/install.sh | sh

–OR–

wget https://runjs.cc/install.sh && sh install.sh

Offline Install

Get file and run it:

https://runjs.cc/localinstall.sh

RunJS Command Line

$ runjs
runjs - Run JSSP-JS script.

ERROR: NO arguments assigned!
CMD: runjs file.js | -u url | -s script | -i | -I
OR : runjs-debug file.js | -u url | -s script | -i | -I
  file.js        assign script file name
  -u url         assign url name
  -s script      assign script content
  -i             interactive
  -I             standard input

Interactive Mode

$ runjs -i
script> println('Hello World.');
Hello World.
+ Result: null
script> exit()
+ Bye!

Execute From Standard Input

$ echo 'println("Hello World.")' | runjs -I
Hello World.
$ curl -sSL https://runjs.cc/helloworld.js | runjs -I
Hello: hatterjiang
$ runjs -I <<< "
xprintln('[OK] SUCCESS!');
"
$ runjs -I << EOF
xprintln('Hello World!');
EOF

Sample - Hello World

$ cat f.js
var main = () => {
    println("Hello World!");
};

main();


$ runjs f.js
Hello World!

Sample - Listing Files

$ cat f.js 
var main = () => {
    $ARRAY($$.file($$.env('HOME')).list())
          .filter((f) => { return f.startsWith('hatter') })
          .filter((f) => { return f.endsWith('.asc') })
          .forEach((f) => { println(f) });
};

main();


$ runjs f.js 
hatter_pgp_2048_c.asc
hatterpubkey4096.asc

Sample - aes.js

$ cat aes.js
#! /usr/bin/env runjs
var AESCrypt = Packages.me.hatter.tools.commons.security.crypt.AESCrypt;

var main = () => {
  AESCrypt.main($ARGS);
};

main();


>> More Samples