Here you can find the source of getClasspath()
public static URL[] getClasspath()
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; public class Main { private static final Class<?>[] noparams = new Class[0]; /**//from ww w.ja va2 s . c o m * Get the current classpath. * @return the current classpath or the empty array if an error occurs. */ public static URL[] getClasspath() { URLClassLoader sysloader = (URLClassLoader) ClassLoader.getSystemClassLoader(); Class<?> sysclass = URLClassLoader.class; try { Method method = sysclass.getDeclaredMethod("getURLs", noparams); method.setAccessible(true); return (URL[]) method.invoke(sysloader, new Object[0]); } catch (Throwable t) { return new URL[0]; } } }