Shawn Zhang
Shawn Zhang

Reputation: 1884

fail to start clojure.jar without build tool

I am restricted in a server env without internet access and not allowed to change any system settings /including env variables.

There are clojure-1.10.1.jar core.specs.alpha-0.2.44.jar spec.alpha-0.2.176.jar in local folder(windows 10).

when I try to run clojure.jar with clojure.main as entry point,here is the error:

 java -cp clojure-1.10.1.jar:spec.alpha-0.2.176.jar:core.specs.alpha-0.2.44.jar clojure.main

enter image description here

but if I run with -jar option on clojure.jar, it seems that java can find the entry point (while it can't find dependence for spec,core.spec.

java -jar clojure-1.10.1.jar

enter image description here enter image description here

My question is, how can I start a repl via command line without leningen/boot/clj ?

Upvotes: 0

Views: 100

Answers (1)

andy_fingerhut
andy_fingerhut

Reputation: 1516

The original question did not mention that the asker was using the Windows operating system. On a Linux or macOS system, this command works just fine if all of the 3 mentioned jar files are located in the current directory where the command is run:

java -cp clojure-1.10.1.jar:spec.alpha-0.2.176.jar:core.specs.alpha-0.2.44.jar clojure.main

If I then remove the file clojure-1.10.1.jar from that directory, and run the command again, I get the same error message as you show in the question. So it is advisable with that error message to double check that those files are actually in the current directory where that java command is being executed, or some other directory.

On a Windows system, the semicolon (;) character is the standard separator character used to separate multiple file names or directory names in a list of such things, not the colon (:), so this command works for Windows:

    java -cp clojure-1.10.1.jar;spec.alpha-0.2.176.jar;core.specs.alpha-0.2.44.jar clojure.main

See the discussion at the following link for why that difference in separator characters exists between Windows versus Linux/macOS: https://www.quora.com/Why-is-the-Java-classpath-separator-a-semicolon-on-Windows-and-a-colon-on-other-OSs-Is-there-a-certain-reason-for-Windows

Upvotes: 3

Related Questions