Java Jar File Find findJarsFromDirectory(File targetDirectory)

Here you can find the source of findJarsFromDirectory(File targetDirectory)

Description

find Jars From Directory

License

Open Source License

Declaration

public static URL[] findJarsFromDirectory(File targetDirectory) 

Method Source Code


//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;
    }
}

Related

  1. findJarEntry(String entryName, JarInputStream jarFile)
  2. findJarFiles(String[] classPathLines)
  3. findJars(File folder)
  4. findJars(File libDir)
  5. findJarsDir(String sparkHome, String scalaVersion, boolean failIfNotFound)
  6. findJarsNamesInPath(String path)
  7. getJarFile(@Nonnull Class clazz)
  8. getJarFile(Class clazz)
  9. getJarFile(Class clazz)