Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
public Collection<Class<?>> getAllClassesFromPath(String path) throws MalformedURLException, Exception {
Collection <File> classes = new FileUtil().listAllClassFiles(path) ;
Collection<Class<?>> result = new ArrayList<Class<?>>(classes.size());
URL urls[] = new URL[1];
if (!path.endsWith(File.separator)) {
path +=File.separator;
}
urls[0] = (new File(path)).toURI().toURL();
URLClassLoader ucl = new URLClassLoader(urls);
for (File classFile : classes) {
String classFilePath = classFile.getAbsolutePath().replace(path, "").replace(".class", "").replace(File.separator, ".");
if (classFilePath.startsWith(".")) {
classFilePath = classFilePath.substring(1);
}
try {
result.add(ucl.loadClass(classFilePath));
}catch(Exception ex) {
log.error("WARNING : COULD NOT LOAD "+classFilePath+" LOCATED AT "+classFile.getAbsolutePath()+" REASON : "+ex.getMessage());
throw ex;
}
}
return result;
}
final URL extLibUrl = new URL("file", "localhost", file.getAbsolutePath());
URLClassLoader loader = new URLClassLoader(new URL[]{extLibUrl});
loader.class("foo.batz");