I'm trying to get a Java/Clojure interop program running using IntelliJ, Cursive, and Leiningen on Windows 10.
The program executes one line. On the 2nd executable line it fails with FileNotFoundException for a file that (to me) should be in the classpath. Examining the classpath from the console, I'm sure it isn't.
Why isn't Listening.clj in the classpath? I can't see what's wrong.
Here's the code where it fails:
static void main (String[] args) // Start execution here, I think.
{
IFn R = Clojure.var ("clojure.core", "require"); // Look up Clojure's 'Require' function.
R.invoke (Clojure.read ("Listening")); // Use it to get the Clojure namespace for 'Listening'.
boolean b = StartHearing (true, 2048); // Initialize storage, prep for hearing, start hearing.
if (!b) System.exit (-1); // No microphone, no hearing, no listening.
StartListening (true); // Start the Java side of listening.
//
// The first part of Listening is now happening asynchronously.
// Subsequent Listening processing will be done in Clojure (design decision).
//
IFn Listening1 = Clojure.var ("Listening", "Listening1"); // Locate "Listening1" in "Listening"
Object result = Listening1.invoke (); // Hopefully invoke the Listening1 function in Listening.clj
}
Here's the runtime error message. Execution terminated at the R.invoke call on the 2nd line.
Exception in thread "main" java.io.FileNotFoundException: Could not locate Listening__init.class, Listening.clj or Listening.cljc on classpath.
at clojure.lang.RT.load(RT.java:482)
at clojure.lang.RT.load(RT.java:444)
at clojure.core$load$fn__6931.invoke(core.clj:6189)
at clojure.core$load.invokeStatic(core.clj:6188)
at clojure.core$load.doInvoke(core.clj:6172)
at clojure.lang.RestFn.invoke(RestFn.java:411)
at clojure.core$load_one.invokeStatic(core.clj:5961)
at clojure.core$load_one.invoke(core.clj:5956)
Here's "Listening.clj":
(ns Listening
(:require Hearing)
(:require StdDraw)
(:gen-class)
)
(defn Listening1
;;
;; Set up drawing canvas, pen, etc. once for a graphic display.
;; Draw a graph of what we get. This drawing is just for diagnostics.
;;
(.StdDraw .setXscale 0 (double .Haperture)) ;; Range of horizontal values.
(.StdDraw .setYscale 0 1.0) ;; Range of vertical values.
(.StdDraw .enableDoubleBuffering) ;; We draw off-line, then show() one graph at a time.
(.StdDraw .setPenColor .StdDraw .RED) ;; Draw in color.
(.StdDraw .setPenRadius 0.003) ;; Draw a thin line.
;;
;; Loop here. Draw graphs of what has been heard. This is just for diagnostic purposes.
;;
(while true ;; Listen continuously to what's been heard.
(if (.FreshMags) ;; If there are new sounds ("magnitudes") to listen to...
(do
(.MagNReadLock.lock) ;; Don't read the Magnitudes until I'm done drawing them.
(.StdDraw.clear) ;; Start out with a blank canvas.
(dotimes [i .Haperture] ;; For all FFT'd audio samples in channel 1...
(.StdDraw.line i 0.0 i (.double .Magnitudes1 [i]))) ;; Draw vertical line, height is Magnitude at sample i.
(.show) ;; Show the now-freshly-drawn graphic.
(set! (.FreshMags) false) ;; Reset the mutable flag. No more fresh magnitudes for now.
(.MagNReadLock.unlock)) ;; Let everybody read the magnitudes again.
(do ;; If there aren't any fresh magnitudes for us to display,
(Thread/sleep 1)))) ;; relinquish the thread for a moment.
)
Here's "project.clj":
(defproject Listening "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "https://example.com/chit260731"
:main jvm.Hearing
:license {:name "EPL-2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}
:dependencies [[org.clojure/clojure "1.12.0"]
[com.github.wendykierp/JTransforms "3.1"]]
;;:repl-options {:init-ns chit260731.core}
:source-paths ["src/clj"]
:java-source-paths ["src/jvm"]
:target-path "target/%s"
:prep-tasks ["javac" "compile"]
:global-vars {*warn-on-reflection* true}
:profiles {:uberjar {:aot :all}}
:resource-paths ["resources"])