Java ClassPath findClassPaths()

Here you can find the source of findClassPaths()

Description

find Class Paths

License

Open Source License

Declaration

@SuppressWarnings("deprecation")
    public static List<URL> findClassPaths() 

Method Source Code


//package com.java2s;
import java.io.File;

import java.net.MalformedURLException;
import java.net.URL;

import java.util.ArrayList;

import java.util.List;

import java.util.StringTokenizer;

public class Main {
    @SuppressWarnings("deprecation")
    public static List<URL> findClassPaths() {
        List<URL> list = new ArrayList<URL>();
        String classpath = System.getProperty("java.class.path");
        StringTokenizer tokenizer = new StringTokenizer(classpath, File.pathSeparator);

        while (tokenizer.hasMoreTokens()) {
            String path = tokenizer.nextToken();
            File fp = new File(path);
            if (!fp.exists())
                throw new RuntimeException("File in java.class.path does not exist: " + fp);
            try {
                list.add(fp.toURL());// w  ww  .j av  a 2  s  .c om
            } catch (MalformedURLException e) {
                throw new RuntimeException(e);
            }
        }
        return list;
    }
}

Related

  1. dumpClasspath(ClassLoader loader)
  2. existsInClasspath(Class clazz, String fileName)
  3. existsInClasspath(final String fileName)
  4. fillClassPath(ClassLoader cl, StringBuffer classpath)
  5. findClassPaths()
  6. findClasspathsByLoader(ClassLoader loader)
  7. findClassPathsToEn()
  8. findDirectoryFromClasspath(Class cls, String file)
  9. findResourceOnClasspath(String resourceName)