JavaShell (Groovy 5.0.0)

Package: org.apache.groovy.util

## [Java] Class JavaShell

- org.apache.groovy.util.JavaShell

-     @Incubating
      public class JavaShell
      extends Object

  A shell for compiling or running pure Java code

- - ### Constructor Summary

    Constructors
    Constructor and description
    `JavaShell()` Initializes a newly created `JavaShell` object
    `JavaShell(ClassLoader parentClassLoader)` Initializes a newly created `JavaShell` object

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public Class<?>` | `compile(String className, Iterable<String> options, String src)` Compile and return the main class
    `` | `public Class<?>` | `compile(String className, String src)` Compile and return the main class
    `` | `public Map<String, Class<?>>` | `compileAll(String className, Iterable<String> options, String src)` Compile and return all classes
    `` | `public Map<String, Class<?>>` | `compileAll(String className, String src)` Compile and return all classes
    `` | `public JavaShell.JavaShellClassLoader` | `getClassLoader()` When and only when compile(String, String) or compileAll(String, String) is invoked, returned class loader will reference the compiled classes.
    `` | `public void` | `run(String className, Iterable<String> options, String src, String args)` Run main method
    `` | `public void` | `run(String className, String src, String args)` Run main method

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### public JavaShell()

      Initializes a newly created `JavaShell` object

    - #### public JavaShell(ClassLoader parentClassLoader)

      Initializes a newly created `JavaShell` object

      Parameters:
        `parentClassLoader` - the parent class loader for delegation

  - ### Method Detail

    - #### public Class<?> compile(String className, Iterable<String> options, String src)

      Compile and return the main class

      Parameters:
        `className` - the main class name
        `options` - compiler options
        `src` - the source code
      Returns:
        the main class

    - #### public Class<?> compile(String className, String src)

      Compile and return the main class

      Parameters:
        `className` - the main class name
        `src` - the source code
      Returns:
        the main class

    - #### public Map<String, Class<?>> compileAll(String className, Iterable<String> options, String src)

      Compile and return all classes

      Parameters:
        `className` - the main class name
        `options` - compiler options
        `src` - the source code
      Returns:
        all classes

    - #### public Map<String, Class<?>> compileAll(String className, String src)

      Compile and return all classes

      Parameters:
        `className` - the main class name
        `src` - the source code
      Returns:
        all classes

    - #### public JavaShell.JavaShellClassLoader getClassLoader()

      When and only when compile(String, String) or compileAll(String, String) is invoked, returned class loader will reference the compiled classes.

    - #### public void run(String className, Iterable<String> options, String src, String args)

      Run main method

      Parameters:
        `className` - the main class name
        `options` - compiler options
        `src` - the source code
        `args` - arguments for main method

    - #### public void run(String className, String src, String args)

      Run main method

      Parameters:
        `className` - the main class name
        `src` - the source code
        `args` - arguments for main method