Package org.apache.groovy.util
Class JavaShell
java.lang.Object
org.apache.groovy.util.JavaShell
A shell for compiling or running pure Java code
- 
Constructor SummaryConstructorsConstructorDescriptionInitializes a newly createdJavaShellobjectJavaShell(ClassLoader parentClassLoader) Initializes a newly createdJavaShellobject
- 
Method SummaryModifier and TypeMethodDescriptionClass<?>Compile and return the main classClass<?>Compile and return the main classcompileAll(String className, Iterable<String> options, String src) Compile and return all classescompileAll(String className, String src) Compile and return all classesorg.apache.groovy.util.JavaShell.JavaShellClassLoaderWhen and only whencompile(String, String)orcompileAll(String, String)is invoked, returned class loader will reference the compiled classes.voidRun main methodvoidRun main method
- 
Constructor Details- 
JavaShellpublic JavaShell()Initializes a newly createdJavaShellobject
- 
JavaShellInitializes a newly createdJavaShellobject- Parameters:
- parentClassLoader- the parent class loader for delegation
 
 
- 
- 
Method Details- 
runpublic void run(String className, Iterable<String> options, String src, String... args) throws Throwable Run main method- Parameters:
- className- the main class name
- options- compiler options
- src- the source code
- args- arguments for main method
- Throws:
- Throwable
 
- 
runRun main method- Parameters:
- className- the main class name
- src- the source code
- args- arguments for main method
- Throws:
- Throwable
 
- 
compilepublic Class<?> compile(String className, Iterable<String> options, String src) throws IOException, ClassNotFoundException Compile and return the main class- Parameters:
- className- the main class name
- options- compiler options
- src- the source code
- Returns:
- the main class
- Throws:
- IOException
- ClassNotFoundException
 
- 
compileCompile and return the main class- Parameters:
- className- the main class name
- src- the source code
- Returns:
- the main class
- Throws:
- IOException
- ClassNotFoundException
 
- 
compileAllpublic Map<String,Class<?>> compileAll(String className, Iterable<String> options, String src) throws IOException, ClassNotFoundException Compile and return all classes- Parameters:
- className- the main class name
- options- compiler options
- src- the source code
- Returns:
- all classes
- Throws:
- IOException
- ClassNotFoundException
 
- 
compileAllpublic Map<String,Class<?>> compileAll(String className, String src) throws IOException, ClassNotFoundException Compile and return all classes- Parameters:
- className- the main class name
- src- the source code
- Returns:
- all classes
- Throws:
- IOException
- ClassNotFoundException
 
- 
getClassLoaderpublic org.apache.groovy.util.JavaShell.JavaShellClassLoader getClassLoader()When and only whencompile(String, String)orcompileAll(String, String)is invoked, returned class loader will reference the compiled classes.
 
-