Help running clojure

This is where you talk about the EV3 software itself, installation issues, and programming talk.

Moderators: roger, gloomyandy, skoehler

New User
Posts: 2
Joined: Tue Oct 15, 2013 10:28 am

Help running clojure

Postby Lunactic » Tue Nov 05, 2013 1:02 pm

Sorry for hijacking this topic, but I've seen that skoehler is running the leJOS for EV3 with clojure.

I'm trying to do the same thing at the moment, but I'm stuck with a strange error.

I shortly explain what I did and where I run into problems:

- I use the actual 1.5.1 clojure version.
- I used lein localrepo to create a maven repository of the ev3classes.jar aswell as the jna 4.0 API
- I created a new clojure project and my project.clj looks like the following:

Code: Select all

(defproject cloj-lego "0.1.0-SNAPSHOT"
  :license {:name "Eclipse Public License"
            :url ""}
  :resource-paths ["lib/local*"]
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [ev3classes "1.0.0"]
                 [jna "4.0.0"]
                 [jna-platform "4.0.0"]]
  :main cloj-lego.core)

- My core.clj looks like the following:

Code: Select all

(ns cloj-lego.core
  (:import [lejos.hardware.Button])
  (:import [lejos.hardware.LCD])
  (:import [lejos.hardware.Sound])
  (:import [lejos.utility.Delay])
  (:import [javax.microedition.lcdui.Font])
  (:import [javax.microedition.lcdui.Graphics])

(defn -main [& args]
  ;; work around dangerous default behaviour in Clojure
  (alter-var-root #'*read-eval* (constantly false))
  (println "Running...")
  ;;(doseq [url (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader)))]
  ;;(println (.getFile url)))
  (def screen-width    (lejos.hardware.LCD/SCREEN_WIDTH))

But whenever I try to compile or run it, i get the following error message:

CompilerException java.lang.NoClassDefFoundError: Could not initialize class lejos.hardware.LCD, compiling:(cloj_lego/core.clj:16:24)

Do you have any suggestion on how to fix this error?
Or can you advise me on how to set it up correctly?

Any help would be appreciated.

User avatar
leJOS Team Member
Posts: 4314
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Help running clojure

Postby gloomyandy » Tue Nov 05, 2013 1:34 pm

I've split this from the other topic as you may get more help that way.

It looks like you are using the packages from the leJOS git master (note that this code is not stable at the moment, we recommend that you use the tagged code). Are you sure that the ev3classes.jar matches this structure? It will certainly not do so if you are using the ev3classes.jar that is supplied with any of our released SD card releases.

New User
Posts: 5
Joined: Sat Oct 26, 2013 12:04 am

Re: Help running clojure

Postby ezephyr » Fri Nov 08, 2013 11:44 pm

Hey, it's not really an answer to your specific question but I have a different solution to getting clojure running on the EV3 on my github. It's pretty straightforward, and I tried to put a reasonable amount of documentation in the readme for the project. Feel free to file issues if you have problems getting it running.

Return to “EV3 Software”

Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 2 guests