i use bash shell to call js using rhino.
ex:
java -jar ../path/to/js.jar ex1.js $*
java -jar ../path/to/js.jar ex2.js $*
java -jar ../path/to/js.jar ex3.js $*
ex1,ex2,ex3 are different javacript project and excute easy script(
like as only print for test). must it write many times [java -jar
../path/to/js.jar ] ? it is very slowly to start java to excute ex1(2,3).js
everytime.
coz it will let %cpu high to start java everytime.
thanks.
peggy.
The JS shell can evaluate multiple files:
$ java -jar js.jar -help
Usage: java org.mozilla.javascript.tools.shell.Main [options...] [files]
Valid options are:
-?, -help Displays help messages.
-w Enable warnings.
-version 100|110|120|130|140|150|160|170
Set a specific language version.
-opt [-1|0-9] Set optimization level.
-f script-filename Execute script file, or "-" for interactive.
-e script-source Evaluate inline script.
-debug Generate debug code.
-strict Enable strict mode warnings.
-fatal-warnings Treat warnings as errors.
-encoding charset Use specified character encoding as default when
reading scripts.
$ cat a.js
print("hello")
$ cat b.js
print("there")
$ java -jar js.jar -f a.js -f b.js
hello
there
Although the usage information says "[files]" at the end, it seems you
can only list a single file (if you don't use the "-f" option like above).
thanks for replay!
coz i have arguments with the javascript file, like as ex1.js
arg1(ex2.js arg2), how can i cat those js files.
thanks.
"Cameron McCormack" <c...@mcc.id.au> wrote in message
news:z-2dnR5-yLSlKJnW...@mozilla.org...
i do this thing below:
$cat ex1.js ex2.js > ex.js
$java -jar ../path/to/js.jar ex.js
but i must have arguments in every js. how can i do
thanks
"Cameron McCormack" <c...@mcc.id.au> wrote in message
news:z-2dnR5-yLSlKJnW...@mozilla.org...
The shell can only take a single list of arguments to pass to all of the
scripts it runs. You will need to either change your scripts so that
they can all work off the same 'arguments' array or write your own small
Java program that loads the script files and passes the relevant list of
arguments to each of the scripts.
very thanks for ur answer!!
peggy
"Cameron McCormack" <c...@mcc.id.au> wrote in message
news:JYydnYkXj7XSS5nW...@mozilla.org...