Java and Clojure with Leiningen
Asked Answered
P

3

46

Is it possible to easily manage and compile native Java classes alongside Clojure in a project using leiningen?

I am working at a pretty low level (with netty nio) and thinking that some of the plumbing classes would actually be easier to handle as raw java both in terms of constructing the code as well as performance.

Polo answered 25/3, 2011 at 12:3 Comment(0)
R
47

In Leiningen tutorial there is following statement

For projects that include some Java code, you can set the :java-source-path key in project.clj to a directory containing Java files. Then the javac compiler will run before your Clojure code is AOT-compiled, or you can run it manually with the javac task.

so it should work out of box if :java-source-paths option is set

Reece answered 25/3, 2011 at 13:0 Comment(0)
C
58

As of Leiningen 2.x, :java-source-path has been replaced with :java-source-paths, whose value is now specified as a vector rather than a string.

A good place to find a full (up-to-date) documentation of Leiningen features is to peruse the sample project file. In this case, you will see:

:java-source-paths ["src/main/java"]

Comptom answered 9/8, 2012 at 13:31 Comment(1)
Also, for re-compiling and reloading java classes, see Virgil (github.com/ztellman/virgil) and my answer at https://mcmap.net/q/373178/-how-do-i-recompile-and-reload-java-source-code-while-lein-repl-is-running. Vinyasa is obsolete.Chavannes
R
47

In Leiningen tutorial there is following statement

For projects that include some Java code, you can set the :java-source-path key in project.clj to a directory containing Java files. Then the javac compiler will run before your Clojure code is AOT-compiled, or you can run it manually with the javac task.

so it should work out of box if :java-source-paths option is set

Reece answered 25/3, 2011 at 13:0 Comment(0)
A
5

Use Vinyasa - I wrote it especially to deal with this problem

Here is a blog post Dynamic reloading of java code in emacs/nrepl

Alvie answered 3/1, 2014 at 3:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.