Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clojurescript: Error: Could not find or load main class clojure.main

I installed Clojurescript following its quick start guide.

I pulled the git repo to ~/clojurescript. CLOJURESCRIPT_HOME is set ~/clojurescript and clojurescript/bin is added to system path.

When I try to use commands cljsc I get following error

Could not find or load main class clojure.main

How can I solve it?

like image 746
Asur Avatar asked Feb 12 '15 15:02

Asur


3 Answers

I was going through this tutorial today.

I checked here for this error. The version of the standalone jar was correct. The problem was caused by a 'typing mistake' in the core.cljs file. The string "Hello world!" was not in double quotes. Initially the string was in single quotes and included a comma.

The other issue I struggled with was getting the java command to work. I was using a Cygwin64 Terminal.

The correct command for the Cygwin64 Terminal is:

$ java -cp "cljs.jar;src" clojure.main build.clj
like image 89
Chris Hadgis Avatar answered Nov 19 '22 12:11

Chris Hadgis


In my case, I was typing Windows command by mistake which has " in the command + make sure you'll have the cljs.jar in your root folder bes

java -cp cljs.jar:src clojure.main build.clj

I hope it helps someone, one day.:)

like image 34
Mahsa2 Avatar answered Nov 19 '22 11:11

Mahsa2


Alright coming back after 5 years.

This error surfaces when one runs clj --main cljs.main --compile hello-world.core --repl from directory or path which does not have file deps.edn or cljs.jar.

Considering the directory structure at https://clojurescript.org/guides/quick-start,

hello-world  #### Run that command in this directory
├─ src   
│  └─ hello_world
│     └─ core.cljs 
├─ cljs.jar 
└─ deps.edn 

i.e.

$ cd hello-world
$ clj --main cljs.main --compile hello-world.core --repl
like image 3
Asur Avatar answered Nov 19 '22 11:11

Asur