/JavaApplication3

experimenting with java clojure interop

Primary LanguageJava

Example of Clojure, Java and deps.edn struggle

Have you tried to have Clojure and java inter-operation? Did you find that the examples are not suitable for the noobs? You are not alone!

This project is supposed to be an example of simple Netbeans project with some Clojure inter-operation that is supposed to help in search of better solution.

With great help from https://github.com/seancorfield I have managed to modify another app to use Clojure correctly. That can be used a example of an important step leading to refactoring of legacy Ant based java application.

Here I will first remove the folder with clojure deps.edn project and the responder.jar file.

Next I will download 3 files and place them in the lib folder of the project.

  • clojure-1.10.2.jar
  • core.specs.alpha-0.2.56.jar
  • spec.alpha-0.2.194.jar:

and use Netbeans dialogue for adding folders with code and jar files to the classpath.

Maven page https://search.maven.org/artifact/org.clojure/clojure/1.10.2/jar list other dependencies that we will not consider at this point.

I had problem making it run correctly because java and Clojure had different classpaths. Fiddling with Netbeans project properties has fixed it.

https://github.com/stuarthalloway/clojure-from-java

interesting example

https://joelholder.com/2015/10/23/how-to-cleanly-integrate-java-and-clojure-in-the-same-package/

In this version Clojure code is required and invoked from the java class. There is no need to add Clojure sources as in the other Ant project. see the heading Java main class

This shows that we can manipulate classpath on Clojure side, so we can use similar if the lack of classpath is an issue. https://maven.apache.org/plugins-archives/maven-surefire-plugin-2.12.4/examples/configuring-classpath.html