use of javafxlibrary.exceptions.JavaFXLibraryFatalException in project JavaFXLibrary by eficode.
the class ApplicationLauncher method setToClasspath.
@RobotKeyword("Loads given path to classpath.\n\n" + "``path`` is the path to add.\n\n" + "If directory path has asterisk(*) after directory separator all jar files are added from directory.\n" + "\nExample:\n" + "| Set To Classpath | C:${/}users${/}my${/}test${/}folder | \n" + "| Set To Classpath | C:${/}users${/}my${/}test${/}folder${/}* | \n")
@ArgumentNames({ "path" })
public void setToClasspath(String path) {
if (path.endsWith("*")) {
path = path.substring(0, path.length() - 1);
HelperFunctions.robotLog("INFO", "Adding all jars from directory: " + path);
try {
File directory = new File(path);
File[] fileList = directory.listFiles();
for (File file : fileList) {
if (file.getName().endsWith(".jar"))
_addPathToClassPath(file.getAbsolutePath());
}
} catch (NullPointerException e) {
throw new JavaFXLibraryFatalException("Directory not found: " + path + "\n" + e.getMessage(), e);
}
} else {
_addPathToClassPath(path);
}
}
use of javafxlibrary.exceptions.JavaFXLibraryFatalException in project JavaFXLibrary by eficode.
the class ApplicationLauncher method _addPathToClassPath.
private void _addPathToClassPath(String path) {
URLClassLoader classLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
HelperFunctions.robotLog("INFO", "Setting following path to Classpath: " + path);
try {
Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
method.setAccessible(true);
method.invoke(classLoader, (new File(path)).toURI().toURL());
} catch (Exception e) {
throw new JavaFXLibraryFatalException("Problem setting the classpath: " + path, e);
}
}
Aggregations