Here you can find the source of findJarsFromDirectory(File targetDirectory)
public static URL[] findJarsFromDirectory(File targetDirectory)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.net.MalformedURLException; import java.net.URL; public class Main { public static URL[] findJarsFromDirectory(File targetDirectory) { // Retrieve downloaded files which are jars File[] files = targetDirectory.listFiles(); URL[] urls = new URL[files.length]; for (int i = 0; i < files.length; i++) { if (files[i].getName().endsWith(".jar")) { try { //loader.addURL(files[i].toURI().toURL()); urls[i] = files[i].toURI().toURL(); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); }// ww w . j av a 2 s . c o m } } return urls; } }