Java Reference
In-Depth Information
Listing 10-3. Special Comments for the jjs Tool. Contents Are Stored in
jjscomments.js File
# This script will run in scripting mode by the jjs tool
# because it starts with a number sign
// Set the current directory to C:\kishori
$ENV.PWD = "C:\\kishori";
// Get the list of files and directories in the current directory
var str = `ls -F`;
print(str);
The following command runs the script in the jjscomments.js file. The script starts
with the # sign, so the jjs tool will automatically enable the scripting mode:
c:\>jjs jjscomments.js
books/
ejb/
hello.txt
important/
programs/
rmi.log
rmi.policy
scripts/
c:\>
With the jjs tool interpreting a script file with the first # sign as a shell executable,
you can use a shebang ( #! ) at the beginning of the script file to run it as a script
executable. Notice that a shebang is directly supported on Unix-like operating systems.
You will need to include the path to the jjs tool in the shebang, so the script will be
executed by the jjs tool. The script file will be passed to the jjs tool to execute. Because
the script file starts with a # sign (part of the shebang #! ), the jjs tool will automatically
enable the scripting mode. The following is an example of a script using a shebang,
assuming that the jjs tool is located at /usr/bin directory:
#!/usr/bin/jjs
var str = `ls -F`;
print(str);
 
Search WWH ::




Custom Search