AOT compilation newbie mistakes

29 views
Skip to first unread message

Isaac Gouy

unread,
Aug 22, 2010, 2:39:29 PM8/22/10
to Clojure
$ /usr/local/src/jdk1.6.0_18/bin/java -cp .:clojure.jar clojure.main
Clojure 1.2.0
user=> (compile 'clojure.examples.hello)
java.io.IOException: No such file or directory (hello.clj:1)


$ ls clojure/examples
hello.clj


$ cat clojure/examples/hello.clj
(ns clojure.examples.hello
(:gen-class))

(defn -main
[greetee]
(println (str "Hello " greetee "!")))


1) What do I need to do to have the REPL find hello.clj ?

2) How can I AOT compile Clojure files without using the REPL?

Robert McIntyre

unread,
Aug 22, 2010, 6:06:22 PM8/22/10
to clo...@googlegroups.com
I feel like a lot of people have trouble with this (I certainly do!)
so I made this tutorial with working examples to follow.

it's at:

http://www.rlmcintyre.com/iassac-gouy.tar.bz2
or
http://www.bortreb.com/iassac-gouy.tar.bz2

just unpack it into your home directory , read the
README, and play around.

It shows how to compile stuff from the command line and the REPL
and how to make shell-scripts.

happy coding,
--Robert McIntyre

> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@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+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

Wilson MacGyver

unread,
Aug 22, 2010, 7:05:44 PM8/22/10
to clo...@googlegroups.com
On Sun, Aug 22, 2010 at 2:39 PM, Isaac Gouy <igo...@yahoo.com> wrote:
> 2) How can I AOT compile Clojure files without using the REPL?

on this point, I think most people use build tools to do it.

gradle with clojuresque plugin, lein and mvn with clojure plugin will
all do this.

--
Omnem crede diem tibi diluxisse supremum.

Message has been deleted

Isaac Gouy

unread,
Aug 22, 2010, 11:14:06 PM8/22/10
to Clojure


On Aug 22, 3:06 pm, Robert McIntyre <r...@mit.edu> wrote:
> I feel like a lot of people have trouble with this (I certainly do!)
> so I made this tutorial with working examples to follow.


Thanks

$ /usr/local/src/jdk1.6.0_18/bin/java -cp .:clojure.jar -
Dclojure.compile.path=. clojure.main
Clojure 1.2.0
user=> (compile 'clojure.examples.hello)
clojure.examples.hello

$ /usr/local/src/jdk1.6.0_18/bin/java -cp clojure.jar
clojure.examples.hello Fred
Hello Fred!


Is there are reason not to simplify further?

$ cat hello.clj
(ns hello
(:gen-class))

(defn -main
[greetee]
(println (str "Hello " greetee "!")))


$ /usr/local/src/jdk1.6.0_18/bin/java -cp .:clojure.jar -
Dclojure.compile.path=. clojure.main
Clojure 1.2.0
user=> (compile 'hello)
hello


$ /usr/local/src/jdk1.6.0_18/bin/java -cp clojure.jar hello John
Hello John!



Robert McIntyre

unread,
Aug 22, 2010, 7:28:14 PM8/22/10
to clo...@googlegroups.com
oh yes -- please don't do it manually for anything "production"

But, it's good to know what's actually going on behind the scenes,
especially when things stop working :)

--Robert McIntyre

Isaac Gouy

unread,
Aug 23, 2010, 10:57:08 AM8/23/10
to Clojure


On Aug 22, 4:28 pm, Robert McIntyre <r...@mit.edu> wrote:
> oh yes -- please don't do it manually for anything "production"
>
> But, it's good to know what's actually going on behind the scenes,
> especially when things stop working :)


For my simple needs -

java -cp .:clojure.jar -Dclojure.compile.path=.
clojure.lang.Compile hello

- is exactly what I was looking for.
Reply all
Reply to author
Forward
0 new messages