I need to write a Clojure script to create a simple app by using Vaadin.
In Java I cam use some thing like this.
"import com.vaadin.Application;"
But I don't know how to do it in Clojure.
I need to know how to import it and the place I should keep that .jar.
Asked
Active
Viewed 1,633 times
2 Answers
9
There is a build tool for clojure called leiningen.
- Follow these instructions to install it: https://github.com/technomancy/leiningen
- Create a new project
- Put that jar to lib folder
- Import classes you need
For example:
(ns your-project-name.core
(:import (com.vaadin Application)
(com.vaadin.ui Button Form HorizontalLayout)
(com.vaadin.data.Property ValueChangeEvent)))
Also read this article on how to use java classes in clojure: http://java.ociweb.com/mark/clojure/article.html#JavaInterop
Note that clojure does not provide a way to import every class in a Java package without specifying each class explicitly: How do I import the entire package but exclude some in Clojure?
1
I use Vaadin with Clojure as well and I initially had alot of pain. In the end I made sure I wrote alot of example Vaadin applications using Java only. Once I was familiar with Vaadin I wrote alot of example Clojure applications. Once I was proficient in both then I attempted to use Vaadin with Clojure, and I haven't looked back since.

yazz.com
- 57,320
- 66
- 234
- 385
-
Unfortunately I cannot publish the examples made for Clojure and Vaadin together as they are private code owned by my employer, but for Java and Clojure I used publicly available tutorials. However I would recommend the following place to get started: http://dev.vaadin.com/wiki/Articles/ClojureScripting – yazz.com Dec 30 '10 at 06:55
-
Dear Zubair, What is the file structure and what are the things in project.clj. I am not very good in clojure. How to create that structure with "lein" command. Or there is another way...?? Thank you. – Thilina Dec 31 '10 at 07:00
-
Yaa dude.. It's working fine. You are correct, that i should know clojure and vaadin well to do this. Thanks a lot. Keep it up bro. – Thilina Jan 05 '11 at 01:52