Here you can find the source of findJar(File dir)
private static File findJar(File dir)
//package com.java2s; /**/* ww w . j a v a 2 s . c o m*/ * Copyright (c) 2010-2016 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ import java.io.File; public class Main { private static File findJar(File dir) { if (dir == null || !dir.isDirectory()) { return null; } for (File file : dir.listFiles()) { if (file.isDirectory()) { File f = findJar(file); if (f != null) { return f; } } else if (file.getName().trim().toLowerCase().endsWith(".jar")) { return file; } } return null; } }