if (SHOW_PROVIDERS.equalsIgnoreCase(show)) {
processProviders(false);
return;
}
ScriptEngineManager mgr;
try {
mgr = new ScriptEngineManager();
} catch (Error e1) {
System.out.println("Could not create ScriptEngineManager: "+e1);
System.out.println("Checking which factories cannot be instantiated ...");
processProviders(true);
return;
}
final List engineFactories = mgr.getEngineFactories();
if (engineFactories.isEmpty()){
throw new RuntimeException("Could not find any engine factories");
}
final int engineCount = engineFactories.size();
if (SHOW_FACTORIES.equalsIgnoreCase(show)) {
System.err.println("Found "+engineCount+ " engine factories");
for (Iterator iter = engineFactories.iterator(); iter.hasNext();){
ScriptEngineFactory fac = (ScriptEngineFactory) iter.next();
showFactory(fac, false);
}
return;
}
if (language == null && extension == null && inFileName != null) {
int i = inFileName.lastIndexOf('.');
if (i > 0) {
extension = inFileName.substring(i+1);
}
}
if (extension == null && language == null) {
throw new IllegalArgumentException("unable to determine language");
}
try {
ScriptEngine engine;
if (language != null) {
engine = mgr.getEngineByName(language);
if (engine == null){
throw new IllegalArgumentException("unable to find engine using Language: "+language);
}
} else {
engine = mgr.getEngineByExtension(extension);
if (engine == null){
throw new IllegalArgumentException("unable to find engine using Extension: "+extension);
}
}
if (SHOW_ENGINE.equalsIgnoreCase(show)){