I’ve found a few articles about using the Clojure programming language on the BeagleBone Black. However, all of them I’ve seen gloss over the installation steps. I got Clojure 1.6.0 running on my rev B BeagleBone Black (aka BBB from here on) and I’ve outlined the steps to do it in this post. If you haven’t done anything with your BBB yet, plug it in to a free USB port and open
START.htm when it mounts as a drive.
Make sure that your BBB has Internet access via Ethernet. Once it’s connected to an Ethernet network (with DHCP) you can find the IP address and use it from there on out. However, first you need to connect to the BBB using
ssh and the USB-Ethernet bridge interface.
Add a new user and set the password so that you won’t have to run as root. Be sure to change
jwright to your preferred user name.
useradd jwright -m; passwd jwright
Logout (Ctrl+D) and
ssh back in as the new user.
Get the Ethernet IP address (inet addr) if you want.
I installed Java 1.7 via the “Installing Oracle’s JDK on BeagleBone Black” instructions here. I’ve summarized and customized the steps below.
Download the Linux ARM v6/v7 Soft Float ABI JDK for the ARM platform. The download requires you to accept a license agreement, so I downloaded it to my laptop and then used
scp to copy it over to the BBB. The “7u55″ portion of the filename in Listing 5 may vary for you. Your IP address and user name will also vary, of course. I set up a
~/bin directory for my user to put the files in, but you would usually put Java in a location that’s more accessible system-wide like
mkdir ~/bin;cd ~/bin;scp firstname.lastname@example.org:/home/jwright/Downloads/jdk-7u55-linux-arm-vfp-sflt.tar.gz ./
Extract the file you downloaded. I
rm the file after extraction because of the limited space available on the BBB. If you wanted to be even more efficient you could actually extract the archive as you’re copying it across the network.
tar xvf jdk-7u55-linux-arm-vfp-sflt.tar.gz;rm jdk-7u55-linux-arm-vfp-sflt.tar.gz
Add the JDK to your PATH environment variable and make it permanent in
.bashrc. Again, note that the version (55) and user name may vary for you.
cd;echo "export PATH=$PATH:/home/jwright/bin/jdk1.7.0_55/bin" | tee -a .bashrc
Set the JAVA_HOME for your installation, making sure to update the version number and user name.
cd;echo "export JAVA_HOME=/home/jwright/bin/jdk1.7.0_55" | tee -a .bashrc
Source (load) the
.bashrc file and double check to make sure that Java is installed correctly.
source ~/.bashrc;java -version
At this point it would be a good idea to reboot your BBB and run the
java -version command again to make sure that the changes to your bash profile worked.
su -c /sbin/reboot root
After you log back in and check Java, you can download the current version of Clojure. Please check for the proper download link here.
cd ~/bin;wget http://central.maven.org/maven2/org/clojure/clojure/1.6.0/clojure-1.6.0.jar
You can then start the Clojure REPL and you’re at the starting point for using Clojure on the BeagleBone Black.
java -cp ~/bin/clojure-1.6.0.jar clojure.main
If you’re new to Clojure I highly recommend that you give it a try. If you come from an Object Oriented Programming background it takes a shift in thinking, but it’s well worth the investment. Have a look at clojure.org and their documentation section to get started. They also have a helpful community that seems to be continuously growing.