Creating Java with Clojure Using a Cake

Start editing: First of all, I want my Clojure program to use the Java class.

I also got some tips on returning from the cake because they are merging.

If anyone reads this, he can recommend a book for setting up the Java / Clojure build environment than learning Java, I would appreciate it. End edit:

Although I can read Java code, I am not a Java programmer. I am building Clojure core programs that successfully use cake, and you need to create a Java class that will become part of my core Clojure. I cannot figure out how to include MyClass.class in the Clojure construct.

First up is my project.clj, followed by a few lines of the application's .clj file.

(defproject ba1-app "0.0.1-SNAPSHOT" :description "TODO: add summary of your project" :dependencies [[org.clojure/clojure "1.2.1"] [org.clojure/tools.cli "0.1.0"]] :main ba2-app) (ns ba2-app (:gen-class) (:use [clojure.string :only [split]] [clojure.string :only [join]])) (def^:dynamic avail-trans [\W \D]) (def^:dynamic acct-types [[\C 0.02][\S 0.04] [\M 0.06]]) . . . 

1) If the .java file is in the same directory as the .clj application module?

2) What would be the assembly instructions?

Thanks.

+1
source share
1 answer

It is not clear what you want to do. I assume that you want to compile a java class and use clojure in your sources. In this case, you do not need to do anything special. Put your Java classes where you want (let's say dir '/ project_dir / src') and add

 :java-source-path "src" 

into your project.clj file. In this case, java classes will be compiled along with clojure files, and their package root hierarchy will start from the directory you select. Now you can use these classes, like other classes - :import in the form (ns ...) or direct (import ...) .

UPD. You can also mention that you can freely mix the java source directory with your clojure sources, so you can have project.clj parameters :source-path and :java-source-part for this value equal to "src" in this example.

+2
source

All Articles