public class Main extends Object
Can execute scripts interactively or in batch mode at the command line. An example of controlling the JavaScript engine.
| Modifier and Type | Field and Description |
|---|---|
protected static ToolErrorReporter |
errorReporter |
protected static int |
exitCode |
static Global |
global |
static ShellContextFactory |
shellContextFactory |
| Constructor and Description |
|---|
Main() |
| Modifier and Type | Method and Description |
|---|---|
static int |
exec(String[] origArgs)
Execute the given arguments, but don't System.exit at the end.
|
static PrintStream |
getErr() |
static Global |
getGlobal() |
static InputStream |
getIn() |
static PrintStream |
getOut() |
static void |
main(String[] args)
Main entry point.
|
static void |
processFile(Context cx,
Scriptable scope,
String filename) |
static void |
processFileNoThrow(Context cx,
Scriptable scope,
String filename) |
static String[] |
processOptions(String[] args)
Parse arguments.
|
static void |
processSource(Context cx,
String filename)
Evaluate JavaScript source.
|
static void |
setErr(PrintStream err) |
static void |
setIn(InputStream in) |
static void |
setOut(PrintStream out) |
public static ShellContextFactory shellContextFactory
public static Global global
protected static ToolErrorReporter errorReporter
protected static int exitCode
public static void main(String[] args)
Process arguments as would a normal Java program. Also create a new Context and associate it with the current thread. Then set up the execution environment and begin to execute scripts.
public static int exec(String[] origArgs)
public static Global getGlobal()
public static void processSource(Context cx, String filename) throws IOException
cx - the current contextfilename - the name of the file to compile, or null for interactive mode.IOException - if the source could not be readRhinoException - thrown during evaluation of sourcepublic static void processFileNoThrow(Context cx, Scriptable scope, String filename)
public static void processFile(Context cx, Scriptable scope, String filename) throws IOException
IOExceptionpublic static InputStream getIn()
public static void setIn(InputStream in)
public static PrintStream getOut()
public static void setOut(PrintStream out)
public static PrintStream getErr()
public static void setErr(PrintStream err)
Copyright © 2025 HtmlUnit. All rights reserved.