Here you can find the source of printClassPath(boolean single)
public static void printClassPath(boolean single)
//package com.java2s; /*/*from ww w. j a v a 2s .c o m*/ * DPCM * Copyright (C) 2014 Jari Kuusisto * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ import java.net.URL; import java.net.URLClassLoader; public class Main { public static void printClassPath(boolean single) { ClassLoader cl = ClassLoader.getSystemClassLoader(); URLClassLoader urlcl = (URLClassLoader) cl; URL[] urls = urlcl.getURLs(); if (single) { String cp = System.getProperty("java.class.path"); System.out.println(cp); } else { for (URL url : urls) { String file = url.getFile(); System.out.println(file); } } } }