Skip to content

Commit e8c4e05

Browse files
committed
Fix classpath handling, closes #38
1 parent 569bf02 commit e8c4e05

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.lang.reflect.Method;
3030
import java.net.URL;
3131
import java.net.URLClassLoader;
32+
import java.nio.file.FileSystems;
3233
import java.util.*;
3334

3435
import static javafxlibrary.utils.HelperFunctions.createThreadedWrapperApplication;
@@ -106,7 +107,7 @@ private Class getMainClass(String appName) {
106107
private void _addPathToClassPath(String path) {
107108
URLClassLoader classLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
108109

109-
RobotLog.info("Setting following path to Classpath: " + path);
110+
RobotLog.info("Setting following path to classpath: " + path);
110111

111112
try {
112113
Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
@@ -133,11 +134,14 @@ public void setToClasspath(String path) {
133134
try {
134135
File directory = new File(path);
135136
File[] fileList = directory.listFiles();
136-
137-
for (File file : fileList) {
138-
if (file.getName().endsWith(".jar"))
137+
boolean jarsFound = false;
138+
for (File file : Objects.requireNonNull(fileList)) {
139+
if (file.getName().endsWith(".jar")) {
140+
jarsFound = true;
139141
_addPathToClassPath(file.getAbsolutePath());
142+
}
140143
}
144+
if(!jarsFound) throw new JavaFXLibraryNonFatalException("No jar files found from classpath: " + FileSystems.getDefault().getPath(path).normalize().toAbsolutePath().toString());
141145
} catch (NullPointerException e) {
142146
throw new JavaFXLibraryFatalException("Directory not found: " + path + "\n" + e.getMessage(), e);
143147
}
@@ -160,7 +164,7 @@ public void logApplicationClasspath() {
160164
}
161165
}
162166

163-
@RobotKeyword("Sets system property ``name`` to ``value``. Equals commmand line usage `-Dname=value`.\n"
167+
@RobotKeyword("Sets system property ``name`` to ``value``. Equals command line usage `-Dname=value`.\n"
164168
+ "\nExample:\n"
165169
+ "| Set System Property | locale | en_US | \n")
166170
@ArgumentNames({ "name", "value" })

0 commit comments

Comments
 (0)