I seem to be doing something wrong. I've built clojure from git, and am invoking it thus:
java -cp clojure.jar clojure.main
I get the repl, and then I type:
(import 'java.lang.string)
and I get:
java.lang.ClassNotFoundException: java.lang.string (NO_SOURCE_FILE:1)
I'm trying this with lang.string since I assume it has to exist on the classpath somewhere. I've tried other libraries, all without much luck. What am I doing wrong?
String
should be capitalized, that's all.
user> (import 'java.lang.String)
java.lang.String
But everything in java.lang
is already imported and available by default, so you shouldn't need to do this.
Btw in non repl exercises probably the best way to include Java classes is the ns macro.
(ns foo.bar
(:refer-clojure :exclude [ancestors printf])
(:require (clojure.contrib sql sql.tests))
(:use (my.lib this that))
(:import (java.util Date Timer Random)
(java.sql Connection Statement)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With