3
admin@apollo:~/clojure$ clojure
Clojure 1.0.0-
user=> (require 'clojure.contrib.str-utils)
java.io.FileNotFoundException: Could not locate clojure/contrib/str_utils__init.class or clojure/contrib/str_utils.clj on classpath:  (NO_SOURCE_FILE:0)
user=> 

What have I done wrong while installing clojure? Why cant clojure locate my java classes? I have java installed.

admin@apollo:~/clojure$ sudo apt-get install sun-java6-jre sun-java6-jdk
sudo: unable to resolve host apollo
Reading package lists... Done
Building dependency tree       
Reading state information... Done
sun-java6-jre is already the newest version.
sun-java6-jdk is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 15 not upgraded.


admin@apollo:~/clojure$ java -version
    java version "1.6.0_20"
    Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
    Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode)
    admin@apollo:~/clojure$ 

please help! thanks!

1
  • Where did you 'get' Clojure, and how did you 'install' it? Commented Sep 16, 2010 at 18:27

3 Answers 3

6

It's great to learn figure this out manually because understanding the classpath makes the world a better place. In practice Many Clojurians use leiningen, maven, or cake.

Personally I would recommend using leiningen:

There are lots of reasons not to use an automated tool and these things dont fit everyone. For the time it takes to set this up its worth it to me even for simple one-liners.

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

3 Comments

there is alsow the cljr project check it out.
Is it not also necessary to run "lein self-install" after downloading the lein script?
i though so, when I checked the leiningen page on gihub that step is not in the getting started instructions. dont think it would hurt to run lein self-install
1

str utils is something that comes with clojure-contrib. It's not a standard java lib. So, simply installing java wont help. When you start clojure make sure the clojure-contrib jar is mentioned in the classpath. You can get the latest(1.2) clojure and clojure-contrib jar from clojure.org

For e.g. This is how i start the REPL

java -server -cp ~/clojure-1.2.0.jar:~clojure-contrib-1.2.0.jar:. clojure.main --repl

5 Comments

thanks for the help, can u be more specific? I tried running that line and I got: pastebin.com/wjBrgDwM
that command is specific to my machine. General way to invoke repl would be : java -cp {path-to-clojure-jar}:{path-to-clojure-contrib-jar}:. clojure.main --repl
@vick: You need to replace the ~/clojure-1.2.0.jar and ~clojure-contrib-1.2.0.jar (<- typo -- should read ~/clojure-contrib...) bits with paths to the actual copies of the relevant jars on your system. From the question text, I gather that you have a copy of clojure.jar in ~/clojure, so you'd use ~/clojure/clojure.jar; if you put the contrib jar in the same directory, the path to it will look similar.
By the way, you can skip the final :. if you don't actually want to include the current directory on the classpath.
I did: updatedb; locate clojure-contrib-1.2.0.jar; and it does not even find the file! how do I install those two jar files?
1

I use maven to handle all dependencies, and it works a treat.

I wrote a blogpost here: http://learnclojure.blogspot.com/2010/08/clojure-emacs-swank-slime-maven-maven.html about how to set up a working clojure/slime setup from scratch on a new machine. It takes about a minute.

Anyway, if all you want is a running repl, then you can:

Install maven

Get the pom.xml from the blogpost, and put it in a directory.

In that directory run $ mvn clojure:repl

Maven will download everything you need and start a repl, which should be jline-enabled so it's actually usable.

I know this works on Ubuntu, it should work fine on all other linuxes and mac osx. Does anyone know if it works on Windows too?

But if you can use emacs, the combination of clojure/emacs and slime is unbeatable. Do let me know if you have any problems.

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.