public static void initContainerForRobocodeEngine(File robocodeHome, IBattleListener listener) { try { if (robocodeHome == null) { robocodeHome = FileUtil.getCwd(); } FileUtil.setCwd(robocodeHome); File robotsDir = FileUtil.getRobotsDir(); if (robotsDir == null) { throw new RuntimeException("No valid robot directory is specified"); } else if (!(robotsDir.exists() && robotsDir.isDirectory())) { throw new RuntimeException( '\'' + robotsDir.getAbsolutePath() + "' is not a valid robot directory"); } } catch (IOException e) { System.err.println(e); return; } // here we cross transition to EngineClassLoader classes using interface which is defined in // system classLoader RobocodeMainBase main = Container.getComponent(RobocodeMainBase.class); main.initForRobocodeEngine(listener); }
private void changeDirectory(String robocodeDir) { try { FileUtil.setCwd(new File(robocodeDir)); } catch (IOException e) { System.err.println(robocodeDir + " is not a valid directory to start Robocode in."); System.exit(8); } }