JRUNSCRIPT(1)
π¦ JRUNSCRIPT(1) β the manual page, but make it make sense π¦
Okay so bestie, listen up π This is the manual page for jrunscript β a command-line script shell that runs scripts in all kinds of languages. It's giving "I contain multitudes" energy, periodt. We're in the JDK Commands section of the manual, and this tool is lowkey experimental and unsupported (more on that in a sec, don't panic).
β¨ NAME β¨
jrunscript β run a command-line script shell that supports interactive and batch modes. No cap, that's literally what it does π«Ά
πΈ SYNOPSIS πΈ
β οΈ Real talk first: This tool is experimental and unsupported. Just so we're clear, bestie π
jrunscript [options] [arguments]
optionsβ the command-line options forjrunscriptthat you can use. Scroll down to [Options](#-options-for-the-jrunscript-command-) for the full tea βargumentsβ when you use them, they go immediately after the options or the command name. See [Arguments](#-arguments-) for the details π
π DESCRIPTION π
The jrunscript command is a language-independent command-line script shell. Iconic behavior, honestly π
It supports two modes of script execution:
- Interactive (read-eval-print) mode β you type, it answers, you vibe π¦
- Batch mode (via the
-foption) β you hand it a file and it does the thing
By default, the language is JavaScript, but you can use the -l option to specify a different language. By using Java-to-scripting-language communication, jrunscript supports an exploratory programming style. It's giving "let's just see what happens" energy and I'm obsessed π§
If JavaScript is used, then before it evaluates a user-defined script, the jrunscript command initializes certain built-in functions and objects. Those are documented in the API Specification for jrunscript JavaScript built-in functions β iykyk π
π OPTIONS FOR THE JRUNSCRIPT COMMAND π
Okay here's the whole menu, bestie. Every single flag, exactly as written, no edits, no cap:
-cp pathor-classpath pathβ tells it where any class files are that the script needs to access. It's giving "here's where my stuff lives" π-Dname=valueβ sets a Java system property. Name equals value, simple as that β¨-Jflagβ passesflagdirectly to the Java Virtual Machine where thejrunscriptcommand is running. Straight to the JVM, no middleman π₯-l languageβ uses the specified scripting language. By default, JavaScript is used. To use other scripting languages, you must specify the corresponding script engine's JAR file with the-cpor-classpathoption. Don't forget the JAR, bestie, or it's not gonna work π-e scriptβ evaluates the specified script. This option can be used to run one-line scripts that are specified completely on the command line. One line, one vibe, done π«-encoding encodingβ specifies the character encoding used to read script files. Let there be (correctly decoded) text π-f script-fileβ evaluates the specified script file (batch mode). File goes in, script comes out π-f -β enters interactive mode to read and evaluate a script from standard input. That dash is not a typo, it's a whole mood π-helpor-?β displays a help message and exits. The classic "wait, how do I use this again" move π-qβ lists all script engines available and exits. A little show-and-tell of what engines you've got π
π ARGUMENTS π
Okay this part is a little conditional, so stay with me:
- If arguments are present and no
-eor-foption is used, then the first argument is the script file and the rest of the arguments, if any, are passed as script arguments. - If arguments and the
-eor the-foption are used, then all arguments are passed as script arguments. - If arguments
-eand-fare missing, then the interactive mode is used. Party time π
π₯ EXAMPLE OF EXECUTING INLINE SCRIPTS π₯
jrunscript -e "print('hello world')"
jrunscript -e "cat('http://www.example.com')"
Look at that. Inline. One line. Slay. π
β EXAMPLE OF USING SPECIFIED LANGUAGE AND EVALUATE THE SCRIPT FILE β
jrunscript -l js -f test.js
Specify the language with -l js, point it at a file with -f test.js, and you're off. Iconic combo π«Ά
π§ EXAMPLE OF INTERACTIVE MODE π§
jrunscript
js> print('Hello World\n');
Hello World
js> 34 + 55
89.0
js> t = new java.lang.Thread(function() { print('Hello World\n'); })
Thread[Thread-0,5,main]
js> t.start()
js> Hello World
js>
The js> prompt is the main character here, obviously π Type, hit enter, watch it go. The t.start() line even sneaks in a Hello World from the thread β it's giving multitasking queen πΈ
π RUN SCRIPT FILE WITH SCRIPT ARGUMENTS π
In this example, the test.js file is the script file. The arg1, arg2, and arg3 arguments are passed to the script. The script can access these arguments with an arguments array. Fr fr, that's how it works π
jrunscript test.js arg1 arg2 arg3
And that's the whole page, bestie! This manual page is from JDK 17, dated 2021 β so if you're reading this in the future, don't come for me about version numbers. Catch you later, go run some scripts πβοΈ
π¦ where this page comes from
- centos-stream 9: java-17-openjdk-devel-slowdebug 1:17.0.20.1.1-1.2.el9 Β· ASL 1.1 and ASL 2.0 and BSD and BSD with advertising and GPL+ and GPLv2 and GPLv2 with exceptions and IJG and LGPLv2+ and MIT and MPLv2.0 and Public Domain and W3C and zlib and ISC and FTL and RSA
- Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms