Mega Code Archive

 
Categories / Java Tutorial / Development
 

Use jrunscript to execute JavaScript scripts

You can use jrunscript in interactive or batch mode to execute scripts. In interactive mode, you can type and execute scripts from the jrunscript prompt. In batch mode, you can load and execute script files using jrunscript. By default, jrunscript executes scripts developed using the JavaScript scripting language. To specify a different language, you can use the –l option while executing jrunscript. jrunscript [options] OptionDescription -classpath pathSpecifies the path to the Java class files. -l languageSpecifies the scripting language. -e scriptEvaluates the given script. -encoding encodingSpecifies the character encoding used while reading script files. -f script-fileEvaluates a script file. -fReads and evaluates a script from the console. This is called interactive mode. -qLists all available script engines. jrunscript -e "print('hello world')"