command line script shell in Mustang

Mustang (Java SE 6) includes (build 51 onwards) jrunscript - a command line scripting shell. This is under $JDK/bin directory. This shell supports script execution both batch and interactive modes. You can choose the scripting language by -l option and list all the available script engines by -q option. The default scripting language is JavaScript.

The usage message of jrunscript looks like:

Usage: jrunscript [options] [arguments...]

where [options] include:
  -classpath <path>    Specify where to find user class files 
  -cp <path>           Specify where to find user class files 
  -D<name>=<value>  Set a system property 
  -J<flag>             Pass <flag> directly to the runtime system 
  -l <language>        Use specified scripting language 
  -e <script>          Evaluate given script 
  -encoding <encoding> Specify character encoding used by script files 
  -f <script file>     Evaluate given script file 
  -f -                 Interactive mode, read script from standard input 
                       If this is used, this should be the last -f option 
  -help                Print this usage message and exit 
  -?                   Print this usage message and exit 
  -q                   List all scripting engines available and exit 
  
If [arguments..] are present and if no -e or -f option is used, then first
argument is script file and the rest of the arguments, if any, are passed
as script arguments. If [arguments..] and -e or -f option is used, then all
[arguments..] are passed as script arguments. If [arguments..], -e, -f are
missing, then interactive mode is used.

You can easily test your script one liners by -e option. For example,

    jrunscript -e "print('hello world')"

jrunscript supports interactive mode. Because of Java-JavaScript integration in Rhino JavaScript engine, interactive mode is a great way to learn Java APIs in Mustang. Nothing like writing few lines of code to learn new API. With jrunscript you can do that just by writing few lines of script!!

Comments:

Post a Comment:
Comments are closed for this entry.
About

sundararajan

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
Bookmarks
Links

No bookmarks in folder

Blogroll

No bookmarks in folder

News

No bookmarks in folder