Stuart Sierra wrote:
> Ok, first you need to add the commons-io.jar to the Java classpath.
> You can do this by editing the Clojure startup script. The argument
> to "-cp" is a colon-separated list of directories and/or JAR files to
> go on the classpath. So if the command line was this:
>
> java -cp /path/to/clojure.jar clojure.lang.Repl
>
> Now it will be:
>
> java -cp /usr/share/java/commons-io.jar:/path/to/clojure.jar
> clojure.lang.Repl
>
> (Note: this may also be possible with the add-classpath function in
> Clojure, but I'm not sure if that still exists/works.)
>
> Once you've done this, restart Clojure and you should be able to
> (import '(org.apache.commons.io FileUtils))
>
> Then call (FileUtils/copyFile fileA fileB)
> fileA and fileB should be instances of java.io.File.
>
> Hope this gets you where you need to be. :)
Yes, thanks very much Stuart. I had tried just about everything you said
except I wasn't prepending the "org.apache." in the import. <sigh>
==> FYI add_classpath works fine.
As a curiosity, I notice that (System/getProperty "java.class.path")
does not reflect any change after add-classpath.
==> I wonder if this is as it should be? And if so, I am left wondering
how to determine the "real" value of the current classpath.
For possible benefit to other newbies, this is what I came up with for
inclusion in (say) user.clj. (criticism welcome)
- - -
;;Copy file (using pathnames) using the Apache.org commons library
(add-classpath "file:///usr/share/java/commons-io.jar")
(import '(org.apache.commons.io FileUtils))
(defn copyfile-byname [src cpy]
(FileUtils/copyFile (java.io.File. src) (java.io.File. cpy)))
- - -
Regards,
..jim
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---