Creating one jar file that for execution from Java/Clojure

前端 未结 2 712
太阳男子
太阳男子 2021-01-15 12:19

I\'d like to create one jar file to execute that is implemented with java and clojure. This is the step that I took.

Making my java code call clojure code

相关标签:
2条回答
  • 2021-01-15 12:57

    As far as I understand your use case is as follows: you have a predominately Java application and you want to make use of some Clojure functions from Java. The best way to do it would be to create a :gen-class which will serve as a Facade to your Clojure functionality. For more information please read this post.

    You'd need to create a separate Clojure project which will be managed by Leiningen. Result of the project you can publish to your local mavan repository (Leiningen is a facade to Maven).

    In Java project add dependency to your Clojure library, you don't have to worry about clojure.jar as Maven will take care of it.

    This is a standard way of developing in Java, please don't crate one monolith Jar with Clojure language and your library in it. If you use Leiningen (Maven) you won't need it.

    Alternative: I know of another way to structure your project, when Clojure and Java sources are kept together. It's dirtier but it works. If you'd like me to describe it, please let me know.

    EDIT: If you configure your project this way it will be always possible to create uberjar of it. Maven has a plugin for that.

    0 讨论(0)
  • 2021-01-15 13:01

    If you want to make an all-inclusive jar, use tools like:

    • Jar Jar Links
    • one-JAR™

    If you specifically want to package jar files, you need a custom classloader, like:

    • JarClassLoader

    That said, I'd consider Dao Wen's suggestion, unless you have a specific need it cannot meet.

    0 讨论(0)
提交回复
热议问题