Main class not found when starting clojure: java -cp clojure.jar clojure.lang.Repl

503 views
Skip to first unread message

HerbM

unread,
Dec 9, 2009, 3:54:52 PM12/9/09
to Clojure
As I was preparing the post a message requesting help for
an error (see below) generated when I entered the quick start
suggest, I realized that suggestion is generic, and not technically
accurate.

java -cp clojure.jar clojure.lang.Repl

Many people may give up without realizing that the VERSION
specific name of the clojure jar must be substituted instead....

java -cp clojure_1.0.0.jar clojure.lang.Repl

While this is entirely obvious once it has been noticed even
once, I figured posting it might help someone else and might
suggest editing the "QuickStart" page recommendation.


==== Message I originally would have posted ====
When running clojure [java -cp clojure.jar clojure.lang.Repl ] the
following error is returned:

Could not find the main class: clojure.lang.Repl


The full display reads:

c:\clojure>java -cp clojure.jar clojure.lang.Repl
Exception in thread "main" java.lang.NoClassDefFoundError: clojure/
lang/Repl
Caused by: java.lang.ClassNotFoundException: clojure.lang.Repl
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: clojure.lang.Repl. Program will exit.

Please tell me what typical things (paths? configs?) to check and fix?

--
HerbM

Stephen C. Gilardi

unread,
Dec 10, 2009, 10:12:38 PM12/10/09
to clo...@googlegroups.com

On Dec 9, 2009, at 3:54 PM, HerbM wrote:

> As I was preparing the post a message requesting help for
> an error (see below) generated when I entered the quick start
> suggest, I realized that suggestion is generic, and not technically
> accurate.
>
> java -cp clojure.jar clojure.lang.Repl
>
> Many people may give up without realizing that the VERSION
> specific name of the clojure jar must be substituted instead....
>
> java -cp clojure_1.0.0.jar clojure.lang.Repl
>
> While this is entirely obvious once it has been noticed even
> once, I figured posting it might help someone else and might
> suggest editing the "QuickStart" page recommendation.

Good catch! Thank you for pointing this out.

The quick start suggestion given in the readme.txt is actually a common way to start Clojure. A clojure.jar file (with that exact name) is generated when you build Clojure from its sources. That file wasn't included in the 1.0.0 distribution, though.

We'll need to make sure that the zip file for Clojure-1.1.0 is internally consistent and whatever instructions are included with it are up to date and work out of the box.

clojure.lang.Repl is also no longer the canonical way to launch a Clojure repl. For Clojure 1.0.0, the suggestion should have been:

java -cp clojure-1.0.0.jar clojure.main

I hope your continued explorations of Clojure are much more fun than getting past this initial hurdle!

Thanks,

--Steve

Reply all
Reply to author
Forward
0 new messages