Java Jar File Find getJarPath(String pkg)

Here you can find the source of getJarPath(String pkg)

Description

get Jar Path

License

Apache License

Declaration

public static URL getJarPath(String pkg) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.net.URL;
import java.util.Enumeration;

public class Main {
    public static URL getJarPath(String pkg) {
        try {//from   w  w w .  j a  v a  2s.com
            Enumeration<URL> resources = Thread.currentThread().getContextClassLoader()
                    .getResources(pkg.replace('.', '/'));
            while (resources.hasMoreElements()) {
                URL url = (URL) resources.nextElement();
                return url;
            }
            return null;
        } catch (Exception e) {
            throw (e instanceof RuntimeException) ? (RuntimeException) e : new RuntimeException(e);
        }
    }
}

Related

  1. getJarLocation(Class clazz)
  2. getJarLocation(final Class cClass)
  3. getJarManifest(File file)
  4. getJarOrDir(Class mainClass)
  5. getJarPath(Class caller)
  6. getJarPathOf(Class classObject)