« September 2005 »
SunMonTueWedThuFriSat
    
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
18
19
20
21
22
23
24
25
27
28
 
       
Today
XML

Blog::Navigation

GetJava Download Button
Get the Source
Personal Blog

Blog::Referers

Today's Page Hits: 144

Powered by Roller Weblogger.
« Previous day (Sep 14, 2005) | Main | Next day (Sep 16, 2005) »
20050916 Friday September 16, 2005

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!!



( Sep 16 2005, 09:09:31 AM IST ) Permalink del.icio.us | furl | simpy | slashdot | technorati | digg

Copyright (C) 2005, A. Sundararajan's Weblog