Java ClassPath printClassPath(boolean single)

Here you can find the source of printClassPath(boolean single)

Description

print Class Path

License

Open Source License

Declaration

public static void printClassPath(boolean single) 

Method Source Code

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

Related

  1. loadFromClasspath(final String configFileName)
  2. loadResourceFromClasspath(Class clazz, String resourceName)
  3. parseClassPath(String classpath)
  4. parseJavaClassPath()
  5. printClassPath()
  6. printJVMClassPath()
  7. readFileFromClasspath(String fileName)
  8. readFromClassPath(String filePath)
  9. readStringFromClasspath(String path, Class c)