Here you can find the source of findJar(String nameRegexp)
public static File findJar(String nameRegexp)
//package com.java2s; //License from project: Apache License import java.io.File; import java.util.ArrayList; import java.util.List; public class Main { public static File findJar(String nameRegexp) { List<File> jars = getFiles(System.getProperty("java.class.path")); for (File jar : jars) { if (jar.getName().matches(nameRegexp)) { return jar; }/*w w w . j a v a 2 s . com*/ } return null; } private static List<File> getFiles(String paths) { List<File> filesList = new ArrayList<>(); for (final String path : paths.split(File.pathSeparator)) { final File file = new File(path); if (file.isDirectory()) { recurse(filesList, file); } else { filesList.add(file); } } return filesList; } private static void recurse(List<File> filesList, File f) { File list[] = f.listFiles(); for (File file : list) { if (file.isDirectory()) { recurse(filesList, file); } else { filesList.add(file); } } } }