1jrunscript(1) General Commands Manual jrunscript(1)
2
3
4
6 jrunscript - command line script shell
7
9 jrunscript [ options ] [ arguments... ]
10
11
13 options
14 Options, if used, should follow immediately after the command name.
15
16 arguments
17 Arguments, if used, should follow immediately after options or com‐
18 mand name.
19
21 jrunscript is a command line script shell. jrunscript supports both an
22 interactive (read-eval-print) mode and a batch (-f option) mode of
23 script execution. This is a scripting language independent shell. By
24 default, JavaScript is the language used, but the -l option can be used
25 to specify a different language. Through Java to scripting language
26 communication, jrunscript supports "exploratory programming" style.
27
28 NOTE: This tool is experimental and may not be available in future ver‐
29 sions of the JDK.
30
32 -classpath path
33 Specify where to find the user's .class files that are accessed by
34 the script.
35
36 -cp path
37 This is a synonym for -classpath path
38
39 -Dname=value
40 Set a Java system property.
41
42 -J<flag>
43 Pass <flag> directly to the Java virtual machine on which jrunscript
44 is run.
45
46 -l language
47 Use the specified scripting language. By default, JavaScript is
48 used. Note that to use other scripting languages, you also need to
49 specify the corresponding script engine's jar file using -cp or
50 -classpath option.
51
52 -e script
53 Evaluate the given script. This option can be used to run "one
54 liner" scripts specified completely on the command line.
55
56 -encoding encoding
57 Specify the character encoding used while reading script files.
58
59 -f script-file
60 Evaluate the given script file (batch mode).
61
62 -f -
63 Read and evaluate a script from standard input (interactive mode).
64
65 -help
66 Output help message and exit.
67
68 -?
69 Output help message and exit.
70
71 -q
72 List all script engines available and exit.
73
75 If [arguments...] are present and if no -e or -f option is used, then
76 the first argument is the script file and the rest of the arguments, if
77 any, are passed as script arguments. If [arguments..] and -e or -f
78 option are used, then all [arguments..] are passed as script arguments.
79 If [arguments..], -e and -f are missing, interactive mode is used.
80 Script arguments are available to a script in an engine variable named
81 "arguments" of type String array.
82
84 Executing inline scripts
85
86 jrunscript -e "print('hello world')"
87 jrunscript -e "cat('http://java.sun.com')"
88
89
90 Use specified language and evaluate given script file
91
92 jrunscript -l js -f test.js
93
94
95 Interactive mode
96
97 jrunscript
98 js>print('hello world');
99 hello world
100 js>34 + 55
101 89
102 js> thread(function() { print('hello world'); }
103 hello world
104 js>
105
106
107 Run script file with script arguments
108
109 jrunscript test.js arg1 arg2 arg3
110
111
112 test.js is script file to execute and arg1, arg2 and arg3 are passed to
113 script as script arguments. Script can access these using "arguments"
114 array.
115
117 If JavaScript is used, then before evaluating any user defined script,
118 jrunscript initializes certain built-in functions and objects. These
119 JavaScript built-ins are documented in jsdocs.
120
121 06 Aug 2006 jrunscript(1)