/** * scans for possible help directories (languages) * * @return a list of possible language directories */ public List<String> getLanguages() { List<String> paths = new ArrayList<>(); URL home = getClass().getResource(".."); File local; if (home != null) { System.out.println("looks like you are not starting from a jar-package"); try { local = new File(new File(home.getPath()).getParentFile().getParentFile(), helproot); System.out.println("local: " + local.getAbsolutePath()); for (File s : local.listFiles()) { if (s.isDirectory() && (s.listFiles().length > 0)) { addToList(paths, s.getName()); } } } catch (Exception e) { System.out.println("but not loading from the developer workbench?!"); } } else { System.out.println("looks like you are starting from a jar-package"); local = CommandLoader.getLocation(); File helpDir = new File(local, helproot); if (helpDir.exists() && helpDir.isDirectory() && (helpDir.listFiles().length > 0)) { for (File s : helpDir.listFiles()) { if (s.isDirectory()) { addToList(paths, s.getName()); } } } File jar = new File(CommandLoader.classPath()); for (File file : local.listFiles()) { try { if (!jar.getCanonicalPath().equals(file.getCanonicalPath())) { searchJarPath(file, paths); } } catch (IOException ignored) { } searchJarPath(jar, paths); } } return paths; }
/** * load from all jars inside the [local] folder (w/o subfolders) * * @param local the folder to look for the jars */ private void initJar(File local) { File jar = new File(CommandLoader.classPath()); loadFromJar(jar); }