clojure classpaths
Clojure is great. I have begun integrating Clojure v1.0 into my current project. I seem to be missing something real easy, ... It seems like every path I set from java -cp is ignored from inside of REPL, main or calling AOT classes. In fact, when I start Clojure from a directory, I have to explicitly (add-classpath file:///some/path/) from REPL to compile clj files in the same directory that I started Clojure from (or any other directory). The best part is that when I enter... (println (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader from REPL, I see the proper classpaths, but can't use them until I explicitly add them with (add-classpath ...). I can get around REPL and main classpath issues easy enough, but I must use AOT compiled classes in my project. I need to call compiled classes from my Java code. I just don't know how to force AOT classes to recognize the java.class.path property. I keep finding new ways to print the exception... Caused by: java.io.FileNotFoundException: Could not locate com/genedavis/clojure/testing/test__init.class or com/genedavis/clojure/testing/test.clj on classpath: at clojure.lang.RT.load(RT.java:398) at clojure.lang.RT.load(RT.java:367) at clojure.core$load__5058$fn__5061.invoke(core.clj:3734) at clojure.core$load__5058.doInvoke(core.clj:3733) at clojure.lang.RestFn.invoke(RestFn.java:413) at clojure.lang.Var.invoke(Var.java:346) Any suggestions? Thanks in advance! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: clojure classpaths
Hi, On Sep 1, 6:58 am, Terrance Davis terrance.da...@gmail.com wrote: It seems like every path I set from java -cp is ignored from inside of REPL, main or calling AOT classes. In fact, when I start Clojure from a directory, I have to explicitly (add-classpath file:///some/path/) from REPL to compile clj files in the same directory that I started Clojure from (or any other directory). For AOT compilation the source files must be reachable as well as the generated .class files. So if you sources are in the src subdirectory and the .class files go to the classes subdirectory, you'll need both subdirectories in the classpath. (Note: with reachable I mean follow the usual convention, namespace foo.bar.baz must be in src/ foo/bar/baz.clj with src in the classpath) Adding . to the classpath should take care of the current working directory. Maybe you can post an example, how you setup your classpath for the JVM and the exact steps to reproduce the error? That makes it easier to help. Sincerely Meikel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: clojure classpaths
Thanks. I should probably clarify. I have managed to compile the classes using (add-classpath ). My problem is using the compiled classes. The example code is here: http://clojure.org/compilation Namely... (ns clojure.examples.hello (:gen-class)) (defn -main [greetee] (println (str Hello greetee !))) and, ... (compile 'clojure.examples.hello) and, ... java -cp ./classes:clojure.jar clojure.examples.hello Fred Calling the main method from the clojure.org doc results in the previously mentioned exception (or package/namespace specific exception) when using clojure v1.0 I have called the main method from the command line. I have called it from Java classes. I have called it with the doc's namespace and mine. It all results in the same exception. My Java classes recognize the -cp argument, and the AOT classes throw the file not found exception. Like I said, I must be missing something real simple. I just can't figure out what it is. Thanks again! On Tue, Sep 1, 2009 at 6:46 AM, Meikel Brandmeyerm...@kotka.de wrote: Hi, On Sep 1, 6:58 am, Terrance Davis terrance.da...@gmail.com wrote: It seems like every path I set from java -cp is ignored from inside of REPL, main or calling AOT classes. In fact, when I start Clojure from a directory, I have to explicitly (add-classpath file:///some/path/) from REPL to compile clj files in the same directory that I started Clojure from (or any other directory). For AOT compilation the source files must be reachable as well as the generated .class files. So if you sources are in the src subdirectory and the .class files go to the classes subdirectory, you'll need both subdirectories in the classpath. (Note: with reachable I mean follow the usual convention, namespace foo.bar.baz must be in src/ foo/bar/baz.clj with src in the classpath) Adding . to the classpath should take care of the current working directory. Maybe you can post an example, how you setup your classpath for the JVM and the exact steps to reproduce the error? That makes it easier to help. Sincerely Meikel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: clojure classpaths
Hi, sorry. I'm off. Your example works for me on 1.5 on Windows as it does work for me on Mac with 1.5 and 1.6. Sincerely Meikel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: clojure classpaths
The details help a lot. I was able to ensure I am doing the same steps with a file not found exception instead of a working file. I notice that the you used 'clojure.jar' whereas I am using 'clojure-1.0.0.jar'. Did you happen to compile your clojure.jar from source? I used the current release download. I am starting to wonder if I need to build from source to get this classpath problem to go away. On Tue, Sep 1, 2009 at 12:05 PM, Krukowkarl.kru...@gmail.com wrote: On Sep 1, 5:03 pm, Terrance Davis terrance.da...@gmail.com wrote: Okay. Here's some additional information. I have tried on OS X 10.6 and Vista and no dice either place. I am NOT This works for me on Mac: krukow:~/examples$ ls -R classes clojure.jar src ./classes: ./src: clojure ./src/clojure: examples ./src/clojure/examples: hello.clj krukow:~/examples$ java -cp clojure.jar:./src:./classes clojure.main Unable to find a $JAVA_HOME at /usr, continuing with system-provided Java... Unable to find a $JAVA_HOME at /usr, continuing with system-provided Java... Clojure 1.1.0-alpha-SNAPSHOT user= (compile 'clojure.examples.hello) clojure.examples.hello user= (clojure.examples.hello.) #hello clojure.examples.he...@dfbabd user= ^D krukow:~/examples$ java -cp clojure.jar:./src:./classes clojure.examples.hello Karl Unable to find a $JAVA_HOME at /usr, continuing with system-provided Java... Unable to find a $JAVA_HOME at /usr, continuing with system-provided Java... Hello Karl! krukow:~/examples$ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: clojure classpaths
you could try running this test script: http://gist.github.com/179346 the script downloads clojure and does a test aot compile. if everything works the only output you should see is Hello World example: hiredman rincewind ~% sh ./clojure-aot-test.sh Hello World On Tue, Sep 1, 2009 at 11:37 AM, Terrance Davisterrance.da...@gmail.com wrote: The details help a lot. I was able to ensure I am doing the same steps with a file not found exception instead of a working file. I notice that the you used 'clojure.jar' whereas I am using 'clojure-1.0.0.jar'. Did you happen to compile your clojure.jar from source? I used the current release download. I am starting to wonder if I need to build from source to get this classpath problem to go away. On Tue, Sep 1, 2009 at 12:05 PM, Krukowkarl.kru...@gmail.com wrote: On Sep 1, 5:03 pm, Terrance Davis terrance.da...@gmail.com wrote: Okay. Here's some additional information. I have tried on OS X 10.6 and Vista and no dice either place. I am NOT This works for me on Mac: krukow:~/examples$ ls -R classes clojure.jar src ./classes: ./src: clojure ./src/clojure: examples ./src/clojure/examples: hello.clj krukow:~/examples$ java -cp clojure.jar:./src:./classes clojure.main Unable to find a $JAVA_HOME at /usr, continuing with system-provided Java... Unable to find a $JAVA_HOME at /usr, continuing with system-provided Java... Clojure 1.1.0-alpha-SNAPSHOT user= (compile 'clojure.examples.hello) clojure.examples.hello user= (clojure.examples.hello.) #hello clojure.examples.he...@dfbabd user= ^D krukow:~/examples$ java -cp clojure.jar:./src:./classes clojure.examples.hello Karl Unable to find a $JAVA_HOME at /usr, continuing with system-provided Java... Unable to find a $JAVA_HOME at /usr, continuing with system-provided Java... Hello Karl! krukow:~/examples$ -- And what is good, Phaedrus, And what is not good— Need we ask anyone to tell us these things? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---