0

To run Clojure files from command line, I'm using a zhs alias I added to my .zshrc:

alias 'clojure=java -cp /home/sinan/cclojure/lib/clojure-1.2.1.jar:/home/sinan/cclojure/lib/clojure-contrib-1.2.0.jar clojure.main -i '

With this, I can run my Clojure app like this:

clojure test3.clj

But it doesn't work when I want to send command line parameters.

➜  src  clojure test3.clj arg1 arg2
Exception in thread "main" java.io.FileNotFoundException: arg1 (No such file or directory)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:120)
        at java.io.FileInputStream.<init>(FileInputStream.java:79)
        at clojure.lang.Compiler.loadFile(Compiler.java:5817)
        at clojure.main$load_script.invoke(main.clj:221)
        at clojure.main$script_opt.invoke(main.clj:273)
        at clojure.main$main.doInvoke(main.clj:354)
        at clojure.lang.RestFn.invoke(RestFn.java:457)
        at clojure.lang.Var.invoke(Var.java:377)
        at clojure.lang.AFn.applyToHelper(AFn.java:172)
        at clojure.lang.Var.applyTo(Var.java:482)
        at clojure.main.main(main.java:37)

What am I doing wrong? Is my way of running Clojure apps wrong?

Thanks.

1 Answer 1

3

you just need to specify name of script, without -i key after clojure.main. In your case, clojure.main thinks, that test.clj is program to eval before (and it do it), while arg1 is script to execute

See description of option for clojure.main/main function

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.