public interface JavaShellToolBuilder
builder()
method. This builder can, optionally, be configured with the configuration methods. All configuration methods return the builder instance for use in chained initialization. All configuration methods have sensible defaults which will be used if they are not called.. After zero or more calls to configuration methods, the tool is launched with a call to run(java.lang.String...)
.Modifier and Type | Method | Description |
---|---|---|
static JavaShellToolBuilder |
builder() |
Create a builder for launching the JDK jshell tool. |
JavaShellToolBuilder |
env |
Set the source for environment variables. |
JavaShellToolBuilder |
err |
Set the error channels. |
JavaShellToolBuilder |
err |
Set the error channels. |
JavaShellToolBuilder |
in |
Set the input channels. |
default JavaShellToolBuilder |
interactiveTerminal |
Set to true to specify the inputs and outputs are connected to an interactive terminal that can interpret the ANSI escape codes. |
JavaShellToolBuilder |
locale |
Set the locale. |
JavaShellToolBuilder |
out |
Set the output channels. |
JavaShellToolBuilder |
out |
Set the output channels. |
JavaShellToolBuilder |
persistence |
Set the storage mechanism for persistent information which includes input history and retained settings. |
JavaShellToolBuilder |
persistence |
Set the storage mechanism for persistent information which includes input history and retained settings. |
JavaShellToolBuilder |
promptCapture |
Set to enable a command capturing prompt override. |
void |
run |
Run an instance of the Java shell tool as configured by the other methods in this interface. |
default int |
start |
Run an instance of the Java shell tool as configured by the other methods in this interface. |
static JavaShellToolBuilder builder()
JavaShellToolBuilder in(InputStream cmdIn, InputStream userIn)
in(System.in, null)
.cmdIn
- source of command inputuserIn
- source of input for running user code, or null
to extract user input from cmdInJavaShellToolBuilder
instanceJavaShellToolBuilder out(PrintStream output)
out(output, output, output)
.out
method is called, the behavior should be equivalent to calling out(System.out)
.output
- destination of command feedback, console interaction, and user code outputJavaShellToolBuilder
instanceJavaShellToolBuilder out(PrintStream cmdOut, PrintStream console, PrintStream userOut)
out
method is called, the behavior should be equivalent to calling out(System.out, System.out, System.out)
.cmdOut
- destination of command feedback including error messages for usersconsole
- destination of console interactionuserOut
- destination of user code output. For example, user snippet System.out.println("Hello")
when executed Hello
goes to userOut.JavaShellToolBuilder
instanceJavaShellToolBuilder err(PrintStream error)
err(error, error)
.err
method is called, the behavior should be equivalent to calling err(System.err)
.error
- destination of tool errors, and user code errorsJavaShellToolBuilder
instanceJavaShellToolBuilder err(PrintStream cmdErr, PrintStream userErr)
err
method is called, the behavior should be equivalent to calling err(System.err, System.err, System.err)
.cmdErr
- destination of tool start-up and fatal errorsuserErr
- destination of user code error output. For example, user snippet System.err.println("Oops")
when executed Oops
goes to userErr.JavaShellToolBuilder
instanceJavaShellToolBuilder persistence(Preferences prefs)
persistence
method is called, the behavior should be to use the tool's standard persistence mechanism.prefs
- an instance of Preferences
that is used to retrieve and store persistent informationJavaShellToolBuilder
instanceJavaShellToolBuilder persistence(Map<String,String> prefsMap)
persistence
method is called, the behavior should be to use the tool's standard persistence mechanism.prefsMap
- an instance of Map
that is used to retrieve and store persistent informationJavaShellToolBuilder
instanceJavaShellToolBuilder env(Map<String,String> vars)
env(System.getenv())
.vars
- the Map of environment variable names to valuesJavaShellToolBuilder
instanceJavaShellToolBuilder locale(Locale locale)
locale(Locale.getDefault())
.locale
- the localeJavaShellToolBuilder
instanceJavaShellToolBuilder promptCapture(boolean capture)
promptCapture(false)
.capture
- if true
, basic prompt is the ENQ
character and continuation prompt is the ACK
character. If false, prompts are as set with set-up or user /set
commands.JavaShellToolBuilder
instancedefault JavaShellToolBuilder interactiveTerminal(boolean terminal)
System.in
, this value is ignored, and the behavior is similar to specifying true
in this method, but is more closely following the specific terminal connected to System.in
.interactiveTerminal(false)
. The default implementation of this method returns this
.terminal
- if true
, an terminal that can interpret the ANSI escape codes is assumed to interpret the output. If false
, a simpler output is selected.JavaShellToolBuilder
instancevoid run(String... arguments) throws Exception
arguments
- the command-line arguments (including options), if anyException
- an unexpected fatal exceptiondefault int start(String... arguments) throws Exception
arguments
- the command-line arguments (including options), if anyException
- an unexpected fatal exception
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/jdk.jshell/jdk/jshell/tool/JavaShellToolBuilder.html