Hi, On Aug 3, 10:16 am, Adie <adit...@gmail.com> wrote:
> for e.g > (import '(javax.persistence Persistence) > gives a > java.lang.ClassNotFoundException: javax.persistence.Persistence > (NO_SOURCE_FILE:0) error > > How will i import javax.persistence properly? You have to name the Classes or Interfaces in the `import` form. (import '(javax.persistence EntityManager EntityManagerFactory Persistence)) If you get a class not found exception, check that everything you need is in your classpath. (java -cp some- require.jar:clojure.jar ....) > How would i define a class that implements this in clojure? > > (ns com.demo.HelloWorld > (:gen-class > :extends [javax.persistence])) Suppose EntityManager is an Interface you do this like that: (ns com.demo.HelloWorld (:gen-class :implements [javax.persistence.EntityManager])) If EntityManager is a class, use: (ns com.demo.HelloWorld (:gen-class :extends javax.persistence.EntityManager)) If you don't need a named class, you can also use `proxy`: (proxy [javax.persistence.EntityManager] [] (methodA [] ...) (methodB [some-arg] ...) ...) > How can i write this effectively in clojure > > EntityManagerFactory emf = > Persistence.createEntityManagerFactory("helloworld"); (let [emf (Persistence/createEntityManagerFactory "helloworld")] ..) Calls to static methods look like qualified calls into a clojure namespace. Note: many details are left out in the above. Read more on http://clojure.org/compilation. You can also look in one of the many clojure projects which might serve as an example. Hope this helps. Sincerely Meikel --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---