Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using custom Java classes in Clojure REPL

In Eclipse, using the CCW plug-in, I want to load a clojure file into a REPL. The problem is that I have an import statement for one of my own java classes, but apparently it is not in my classpath.

(ns my-clj-ns
  (:import [alg.gen Enumerator]))

Do I have to make jars out of every class that I want use/test in a Clojure REPL?

Currently, trying to load my clj into a REPL results in an error: "Load file in Clojure REPL" did not complete normally. Please see the log for more information. java.lang.NullPointerException

Any help would be greatly appreciated.

like image 788
Giles Avatar asked May 11 '26 00:05

Giles


2 Answers

You can let leiningen compile these for you using,

:javac-options {:destdir "classes/"}
:java-source-path "src/main/java" ; location of Java source

options or manually compile them and move the class files to the classes/ directory. No need to create a jar.

like image 97
Hamza Yerlikaya Avatar answered May 12 '26 13:05

Hamza Yerlikaya


When you're in the ccw repl, you can hit alt-e to see the stack trace. If you're getting a NullPointerException, I don't think its a classpath issue.

like image 36
Bill Avatar answered May 12 '26 15:05

Bill



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!