Class Main


  • public class Main
    extends java.lang.Object
    The shell program.

    Can execute scripts interactively or in batch mode at the command line. An example of controlling the JavaScript engine.

    • Constructor Detail

      • Main

        public Main()
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
        Main entry point.

        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.

      • exec

        public static int exec​(java.lang.String[] origArgs)
        Execute the given arguments, but don't System.exit at the end.
      • getGlobal

        public static Global getGlobal()
      • processOptions

        public static java.lang.String[] processOptions​(java.lang.String[] args)
        Parse arguments.
      • processSource

        public static void processSource​(Context cx,
                                         java.lang.String filename)
                                  throws java.io.IOException
        Evaluate JavaScript source.
        Parameters:
        cx - the current context
        filename - the name of the file to compile, or null for interactive mode.
        Throws:
        java.io.IOException - if the source could not be read
        RhinoException - thrown during evaluation of source
      • processFileNoThrow

        public static void processFileNoThrow​(Context cx,
                                              Scriptable scope,
                                              java.lang.String filename)
      • processFile

        public static void processFile​(Context cx,
                                       Scriptable scope,
                                       java.lang.String filename)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • getIn

        public static java.io.InputStream getIn()
      • setIn

        public static void setIn​(java.io.InputStream in)
      • getOut

        public static java.io.PrintStream getOut()
      • setOut

        public static void setOut​(java.io.PrintStream out)
      • getErr

        public static java.io.PrintStream getErr()
      • setErr

        public static void setErr​(java.io.PrintStream err)