Source:
private void setupDirectories(URL directoryName) throws IOException, URISyntaxException { final File mainDirectory = new File(directoryName.toURI()); final File photonDirectory = new File(mainDirectory, "photon_data"); this.esDirectory = new File(photonDirectory, "elasticsearch"); final File pluginDirectory = new File(esDirectory, "plugins"); final File scriptsDirectory = new File(esDirectory, "config/scripts"); final File groovyDirectory = new File(esDirectory, "modules/lang-groovy"); final File painlessDirectory = new File(esDirectory, "modules/lang-painless"); for (File directory : new File[] { esDirectory, photonDirectory, pluginDirectory, scriptsDirectory, groovyDirectory, painlessDirectory }) { directory.mkdirs(); } final ClassLoader loader = Thread.currentThread().getContextClassLoader(); Files.copy(loader.getResourceAsStream("modules/lang-painless/antlr4-runtime-4.5.1-1.jar"), new File(painlessDirectory, "antlr4-runtime-4.5.1-1.jar").toPath(), StandardCopyOption.REPLACE_EXISTING); Files.copy(loader.getResourceAsStream("modules/lang-painless/asm-debug-all-5.1.jar"), new File(painlessDirectory, "asm-debug-all-5.1.jar").toPath(), StandardCopyOption.REPLACE_EXISTING); Files.copy(loader.getResourceAsStream("modules/lang-painless/lang-painless-5.5.0.jar"), new File(painlessDirectory, "lang-painless-5.5.0.jar").toPath(), StandardCopyOption.REPLACE_EXISTING); Files.copy(loader.getResourceAsStream("modules/lang-painless/plugin-descriptor.properties"), new File(painlessDirectory, "plugin-descriptor.properties").toPath(), StandardCopyOption.REPLACE_EXISTING); Files.copy(loader.getResourceAsStream("modules/lang-painless/plugin-security.policy"), new File(painlessDirectory, "plugin-security.policy").toPath(), StandardCopyOption.REPLACE_EXISTING); }

Target:
private void setupDirectories(URL directoryName) throws IOException, URISyntaxException { final File mainDirectory = new File(directoryName.toURI()); final File photonDirectory = new File(mainDirectory, "photon_data"); this.esDirectory = new File(photonDirectory, "elasticsearch"); final File pluginDirectory = new File(esDirectory, "plugins"); final File scriptsDirectory = new File(esDirectory, "config/scripts"); final File painlessDirectory = new File(esDirectory, "modules/lang-painless"); for (File directory : new File[] { photonDirectory, esDirectory, pluginDirectory, scriptsDirectory, painlessDirectory }) { directory.mkdirs(); } final ClassLoader loader = Thread.currentThread().getContextClassLoader(); Files.copy(loader.getResourceAsStream("modules/lang-painless/antlr4-runtime-4.5.1-1.jar"), new File(painlessDirectory, "antlr4-runtime-4.5.1-1.jar").toPath(), StandardCopyOption.REPLACE_EXISTING); Files.copy(loader.getResourceAsStream("modules/lang-painless/asm-debug-all-5.1.jar"), new File(painlessDirectory, "asm-debug-all-5.1.jar").toPath(), StandardCopyOption.REPLACE_EXISTING); Files.copy(loader.getResourceAsStream("modules/lang-painless/lang-painless-5.5.0.jar"), new File(painlessDirectory, "lang-painless-5.5.0.jar").toPath(), StandardCopyOption.REPLACE_EXISTING); Files.copy(loader.getResourceAsStream("modules/lang-painless/plugin-descriptor.properties"), new File(painlessDirectory, "plugin-descriptor.properties").toPath(), StandardCopyOption.REPLACE_EXISTING); Files.copy(loader.getResourceAsStream("modules/lang-painless/plugin-security.policy"), new File(painlessDirectory, "plugin-security.policy").toPath(), StandardCopyOption.REPLACE_EXISTING); }