ianarchist ianarchist - 3 years ago 86
Linux Question

leiningen cannot run because of java class not found exception

I recently--as in, today--became interested in learning to program with clojure. Now after having installed the latest version of java's jdk and downloading the leiningen script, I followed the installation instructions for the latter, specifically those given at: http:/www.lispcast.com/clojure-ubuntu.

Now, after the running

lein version
and downloading the relevant jar file, the program exits with an error about a class not being found. The error in question reads as follows:


Exception in thread "main" java.lang.ExceptionInInitializerError

at java.base/java.lang.Class.forName0(Native Method)

at java.base/java.lang.Class.forName(Class.java:375)>

at clojure.lang.RT.classForName(RT.java:2168)

at clojure.lang.RT.classForName(RT.java:2177)

at clojure.lang.RT.loadClassForName(RT.java:2196)

at clojure.lang.RT.load(RT.java:443)

at clojure.lang.RT.load(RT.java:419)

at clojure.core$load$fn__5677.invoke(core.clj:5893)

at clojure.core$load.invokeStatic(core.clj:5892)

at clojure.core$load.doInvoke(core.clj:5876)

at clojure.lang.RestFn.invoke(RestFn.java:408)

at clojure.core__init.load(Unknown Source)

at clojure.core__init.(Unknown Source)

at java.base/java.lang.Class.forName0(Native Method)

at java.base/java.lang.Class.forName(Class.java:375)

at clojure.lang.RT.classForName(RT.java:2168)

at clojure.lang.RT.classForName(RT.java:2177)

at clojure.lang.RT.loadClassForName(RT.java:2196)

at clojure.lang.RT.load(RT.java:443)

at clojure.lang.RT.load(RT.java:419)

at clojure.lang.RT.doInit(RT.java:461)

at clojure.lang.RT.(RT.java:331)

at clojure.main.(main.java:20)

Caused by: java.lang.ClassNotFoundException: java/sql/Timestamp

at java.base/java.lang.Class.forName0(Native Method)

at java.base/java.lang.Class.forName(Class.java:375)

at clojure.lang.RT.classForName(RT.java:2168)

at clojure.lang.RT.classForNameNonLoading(RT.java:2181)

at clojure.instant$loading__5569__auto____6869.invoke(instant.clj:9)

at clojure.instant__init.load(Unknown Source)

at clojure.instant__init.(Unknown Source)

... 23 more



My java 9 jdk is installed in
/usr/lib/jvm/java-9-oracle/bin/java
, with my
JAVA_HOME
variable set to
/usr/lib/jvm/java-9-oracle
but I tried
/usr/lib/jvm/java-9-oracle/bin
as well, just in case. I am running xubuntu 16.04.3, if this is of any importance. I did try setting the default java jdk back to the openjdk which is bundled with xubuntu but this also was to no avail.

As an aside, the entire problem originated because I tried running the REPL
in intellij after installing the cursive plugin, which didn't work. I then surmised that it might be because I had not installed leiningen beforehand (I thought that the IDE and cursive would have this bundled along). However, the actual information on what intellij and clojure require to run successfully has eluded me, since much of the information is rather 'scattered' and I'm not sure whether I missed something along the way.

In any case, I am having quite a hard time of getting everything to work--probably because I'm not yet that savvy when it comes to these kinds of issues, having only been on a linux distro for a short while as well as being completely unfamiliar with clojure. If I'm missing something obvious, I apologize, but it stands to reason that something can only be obvious once it is shown to be so.

Any and all suggestions will be greatly appreciated.

Answer Source

That looks like a problem caused by Java 9's new concept of "modules": Clojure expects to be able to access java.sql.Timestamp, but it can't. I haven't kept up with Java development or Clojure development, so I can't say for sure that's your problem, but it looks that way to me. Try with an earlier JDK.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download