I'm somewhat new to clojure but I'm a very experienced programmer.
I've written a clojure program to process and rate XMLTV listings (for personal use). The program works fine. It also loads rules written as clojure statements in run time and executes them. I've read that that means that I can't "pre-compile" my program and that I have to run it through the REPL (like this "java -cp clojure-1.4.0.jar clojure-1.4.0.jar my-core.clj my-args"). If this is wrong, please correct me.
The thing is that when I run this in windows, my "main" function in my-core.clj gets the command line just fine, but when I try to run it under Ubuntu 12.04, it either complains about not finding clojure/main or my functions. Not being one to give up, I tried "lein run my-args" (the project is built with Leiningen) but my program gets nil as command-line.
I've also tried -m namespace/func with the same result.
I'm using Leiningen 1.7.1 and Java 1.6.0_24 OpenJDK Client VM
Anyone have any ideas what I'm doing wrong?
Regards Soren Svensson
Thanks!
I made 3 changes,
1) I added (:gen-class)
2) I added a:
(defn -main [cmd-line]
(println (type cmd-line))
(println cmd-line)
(println (type command-line-args))
(println command-line-args))
3) I ran (compile 'xmltvproc.core) from REPL
before, I ended core.clj with a call to my "main" function (run-it *command-line-args*).
My test with -main showed that cmd-line IS the command line but command-line-args is nil.
Running it with lein run arg1 arg2 now works but when I try java -cp ... it still fails.
java -cp ./lib/clojure.jar ./classes/xmltvproc/core arg1 arg2
Exception in thread "main" java.lang.NoClassDefFoundError: //classes/xmltvproc/core
java -cp ./lib/clojure.jar xmltvproc.core arg1 arg2
Exception in thread "main" java.lang.NoClassDefFoundError: clojure/lang/IFn
I've tried all the permutations that I can think of, and the result is always one of the two above.
Here's my project.clj file:
(defproject xmltvproc "1.0.0-SNAPSHOT"
:description "Convert XMLTV listings to CSV file"
:main xmltvproc.core
:dependencies [[org.clojure/clojure "1.4.0"]])
and my xmltvproc/classes/xmltvproc have all the expected .class files
??