Why does Java complain that the namespace is not found?

I am trying to set up the lein build environment in copied files running Windows 7 from a successful build environment on Linux. I have maven and jdk installed along with the lane.

HOME points to c:\Users\cnorton where the maven directories are located.

I get this error when trying to change lein or lein, and I can not understand what I'm doing wrong.

Called: java.lang.Exception: namespace 'repl-test.core' not found after loading '/ repl_test / core'

Here is the .clj project

 (defproject repl-test "0.0.1-SNAPSHOT" :description "TODO: add summary of your project" :dependencies [[org.clojure/clojure "1.4.0"] [org.clojure/clojure-contrib "1.2.0"] [clojure-csv/clojure-csv "1.2.4"] [org.clojure/tools.cli "0.1.0"] [clj-http "0.1.3"]] :aot [repl-test.core] :main repl-test.core) 

Here is the first part of src / repl_test / core.clj

 (ns repl-test.core (:gen-class) (:use clojure.contrib.command-line) (:require [clojure.contrib.string :as cstr]) (:require [clojure.contrib.trace :as ctr]) (:require [clojure.string :as sstr]) (:use clojure-csv.core)) 

It would be very useful for me if someone could post project.clj and the core.clj header as an answer, which allows the project to be the main one.

+4
source share
1 answer

I would avoid "-" in the names of folders and namespaces; it is actually converted to "_", but not in all places.

The following may or may not work for you. I designed your skeleton project:

 (defproject st1 "1.0.0-SNAPSHOT" :description "TODO: add summary of your project" :dependencies [[org.clojure/clojure "1.4.0"] [org.clojure/clojure-contrib "1.2.0"] [clojure-csv/clojure-csv "1.2.4"] [org.clojure/tools.cli "0.1.0"] [clj-http "0.1.3"]] :aot [repl_test.core] :main repl_test.core) 

The same clj file as yours:

  (ns repl_test.core (:gen-class) (:use clojure.contrib.command-line) (:require [clojure.contrib.string :as cstr]) (:require [clojure.contrib.trace :as ctr]) (:require [clojure.string :as sstr]) (:use clojure-csv.core)) 

And I renamed the repl-test folder to repl_test using underscore.

Then

  lein compile 

and

  lein run 

Out of curiosity, I also looked at clojure-csv , and they use "-" everywhere except for the folder name, so it might be possible to copy what they did.

Also, citing another SO question in clojure namespaces:

"Also note that you do not use underscores in name names or hyphens in file names and wherever you use hyphens in namespace names, you must use an underscore in the file name (so ns my.cool project is defined in the file named cool_project.clj in a directory named my).

And from the Clojure Programming Wiki section in java packages: "Clojure complies with Java naming conventions for directories and files, but Lisp has naming conventions for namespace names. Thus, the clojure com.my-app.utils namespace will live along the path com / my_app / utils.clj. Pay particular attention to the underscore / hyphen. "

+6
source

Source: https://habr.com/ru/post/1437705/


All Articles