Search This Blog

Saturday, November 28, 2009

classpath

These expressions keep coming in handy, for finding out what clojure thinks the classpath is today:


(println (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader))))

(pprint (map (memfn getPath) (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader))))) 
 
(clojure.contrib.pprint/pprint (sort (map (memfn getPath) (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader))))))

Thanks Pablo! ( http://pupeno.com/blog/printing-the-class-path-in-clojure/ )

1 comment:

  1. An alternative that uses the system properties rather than the class loader (This is for windows, so you might want to change the ; to : on linux / os x):

    (re-seq #"[^;]+" (System/getProperty "java.class.path"))

    The advantage is that you get rid of the URL objects.

    -- Lauri

    ReplyDelete

Followers