File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Clojure and the fly likes Deploying/Distributing Clojure App Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Languages » Clojure
Bookmark "Deploying/Distributing Clojure App" Watch "Deploying/Distributing Clojure App" New topic
Author

Deploying/Distributing Clojure App

Dan King
Ranch Hand

Joined: Mar 18, 2009
Posts: 84
How does one deploy a Clojure app? Is it like groovy/jruby where you compile your app and include the interpreter jar within the overall jar?
Sean Corfield
Ranch Hand

Joined: Feb 09, 2011
Posts: 267
    
    5

You can package Clojure as source with the compiler and runtime library/ies (Clojure is compiled on the fly to bytecode, it is not interpreted) in a JAR.

You can also compile AOT (Ahead Of Time) to .class files and package those up with the runtime library/ies in a JAR.

If you're building web apps, you can package everything up in a WAR for deployment (the Leiningen build tool makes all of this very easy).

Other options include deploying source code in a folder tree on the classpath, load the entry point scripts with clojure.lang.RT and start invoking code from the host language (the Clojure scripts are compiled to bytecode on the fly, not interpreted). That's mostly how I use Clojure from my web application right now - I can make changes to the Clojure code, and just reload it into the runtime without any restarts needed.

BTW, that reminds me of another point that I don't think has been mentioned yet in threads... It's possible to connect a REPL (Read-Eval-Print-Loop) client to an existing, running Clojure application and run code against it, even hot swapping definitions of variables and functions if you want. That means you can monitor, manage, maintain and update live, running Clojure applications without downtime if you really need to.
Dan King
Ranch Hand

Joined: Mar 18, 2009
Posts: 84
Sean Corfield wrote:Other options include deploying source code in a folder tree on the classpath, load the entry point scripts with clojure.lang.RT and start invoking code from the host language (the Clojure scripts are compiled to bytecode on the fly, not interpreted). That's mostly how I use Clojure from my web application right now - I can make changes to the Clojure code, and just reload it into the runtime without any restarts needed.


As an side, do you use a clojure web framework? If yes, which one and why?
Sean Corfield
Ranch Hand

Joined: Feb 09, 2011
Posts: 267
    
    5

Dan King wrote:As an side, do you use a clojure web framework? If yes, which one and why?

I don't currently. What's available right now are micro-frameworks and I don't yet think Clojure has a strong story for web page templating. Things are definitely improving, and with the Enlive templating library becoming an officially supported "contrib" library for 1.3 there will probably be some good solutions "soon".

What I'm using right now is the JBoss community project Railo which is a fast, free, open source implementation of CFML, originally Allaire's / Macromedia's / Adobe's server side web platform language. Railo's small footprint, fast bytecode compiler, full OO scripting language - as well as the original tag-based templating language - and rich feature set make it the best web framework I've found. Like Clojure it offers edit-refresh-test without a deployment/restart and of course has full interop with Java on the JVM.
Huahai Yang
Greenhorn

Joined: May 25, 2011
Posts: 10
I use compojure for routing and just use hiccup for templating. The lein-ring plugin is very handy for development, as it supports live changes to the application, no reloading is necessary, just refresh the browser, the change is already there.


Dan King wrote:
Sean Corfield wrote:Other options include deploying source code in a folder tree on the classpath, load the entry point scripts with clojure.lang.RT and start invoking code from the host language (the Clojure scripts are compiled to bytecode on the fly, not interpreted). That's mostly how I use Clojure from my web application right now - I can make changes to the Clojure code, and just reload it into the runtime without any restarts needed.


As an side, do you use a clojure web framework? If yes, which one and why?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Deploying/Distributing Clojure App