Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to :use (or :require) a custom file in Clojure?
    primarykey
    data
    text
    <p>Super beginner question here. I'm following the (good) book <em>Programming Clojure</em>, and chapter 5 is about coding a small Snake game. Utility code is provided, and I decided to follow it by starting a new <em>Leiningen</em> project (<code>lein new app snake</code>). In my <code>src/snake/core.clj</code> I'd like to <code>:use</code> a file named <code>import_static.clj</code> written by the authors. I copied the file into <code>src/snake</code>, and in <code>src/snake/core.clj</code> I copied from the samples the import line <code>(:use snake.import-static)</code>. But when I evalute the whole file in the REPL I have this error : "FileNotFoundException Could not locate import_static__init.class or import_static.clj on classpath".</p> <p>Using Clojure 1.5.1, both in the <code>project.clj</code> file and the editor's REPL (SublimeText + plugin SublimeREPL). The directory structure :</p> <pre><code>src/ snake/ core.clj import_static.clj </code></pre> <p>Top of <code>core.clj</code> :</p> <pre><code>(ns snake.core (:import (java.awt Color Dimension) (javax.swing JPanel JFrame Timer JOptionPane) (java.awt.event ActionListener KeyListener)) (:gen-class) (:use snake.import-static)) </code></pre> <p>Top of <code>import_static.clj</code> :</p> <pre><code>(ns ^{:author "Stuart Sierra", :doc "Import static Java methods/fields into Clojure"} snake.import-static (:use clojure.set)) </code></pre> <p>I tried removing the <code>snake</code> from both the <code>:use</code> call and the namespace declaration, with no luck. Can you help me ? Note that I have no knowledge of the JVM, and it may be the classpath or my editor.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload