1JRUNSCRIPT(1)                    JDK Commands                    JRUNSCRIPT(1)
2
3
4

NAME

6       jrunscript  - run a command-line script shell that supports interactive
7       and batch modes
8

SYNOPSIS

10       Note:
11
12       This tool is experimental and unsupported.
13
14       jrunscript [options] [arguments]
15
16       options
17              This represents the jrunscript command-line options that can  be
18              used.  See Options for the jrunscript Command.
19
20       arguments
21              Arguments,  when  used,  follow immediately after options or the
22              command name.  See Arguments.
23

DESCRIPTION

25       The jrunscript command is a  language-independent  command-line  script
26       shell.    The   jrunscript   command   supports   both  an  interactive
27       (read-eval-print) mode and a batch (-f option) mode  of  script  execu‐
28       tion.   By  default, JavaScript is the language used, but the -l option
29       can be used to specify a different language.  By using Java to  script‐
30       ing  language  communication,  the  jrunscript  command supports an ex‐
31       ploratory programming style.
32
33       If JavaScript is used, then before it evaluates a user defined  script,
34       the  jrunscript  command initializes certain built-in functions and ob‐
35       jects, which are documented in the  API  Specification  for  jrunscript
36       JavaScript built-in functions.
37

OPTIONS FOR THE JRUNSCRIPT COMMAND

39       -cp path or -classpath path
40              Indicates where any class files are that the script needs to ac‐
41              cess.
42
43       -Dname=value
44              Sets a Java system property.
45
46       -Jflag Passes flag directly to the Java Virtual Machine where the jrun‐
47              script command is running.
48
49       -l language
50              Uses  the  specified scripting language.  By default, JavaScript
51              is used.  To use other scripting languages, you must specify the
52              corresponding  script  engine's JAR file with the -cp or -class‐
53              path option.
54
55       -e script
56              Evaluates the specified script.  This option can be used to  run
57              one-line  scripts  that  are specified completely on the command
58              line.
59
60       -encoding encoding
61              Specifies the character encoding used to read script files.
62
63       -f script-file
64              Evaluates the specified script file (batch mode).
65
66       -f -   Enters interactive mode to read and evaluate a script from stan‐
67              dard input.
68
69       -help or -?
70              Displays a help message and exits.
71
72       -q     Lists all script engines available and exits.
73

ARGUMENTS

75       If  arguments  are  present and if no -e or -f option is used, then the
76       first argument is the script file and the rest  of  the  arguments,  if
77       any, are passed as script arguments.  If arguments and the -e or the -f
78       option are used, then all arguments are passed as script arguments.  If
79       arguments -e and -f are missing, then the interactive mode is used.
80

EXAMPLE OF EXECUTING INLINE SCRIPTS

82              jrunscript -e "print('hello world')"
83
84              jrunscript -e "cat('http://www.example.com')"
85

EXAMPLE OF USING SPECIFIED LANGUAGE AND EVALUATE THE SCRIPT FILE

87              jrunscript -l js -f test.js
88

EXAMPLE OF INTERACTIVE MODE

90              jrunscript
91              js> print('Hello World\n');
92              Hello World
93              js> 34 + 55
94              89.0
95              js> t = new java.lang.Thread(function() { print('Hello World\n'); })
96              Thread[Thread-0,5,main]
97              js> t.start()
98              js> Hello World
99
100              js>
101

RUN SCRIPT FILE WITH SCRIPT ARGUMENTS

103       In  this example, the test.js file is the script file.  The arg1, arg2,
104       and arg3 arguments are passed to the script.   The  script  can  access
105       these arguments with an arguments array.
106
107              jrunscript test.js arg1 arg2 arg3
108
109
110
111JDK 17                               2021                        JRUNSCRIPT(1)
Impressum