Jun 08

How to install zeromq (0MQ) in Ubuntu with Java bindings

403 Forbidden

Forbidden

You don't have permission to access /devformatter/branches/langs/autoconf.php on this server.


Apache Server at svn.wp-plugins.org Port 80
403 Forbidden

Forbidden

You don't have permission to access /devformatter/branches/langs/autoconf.php on this server.


Apache Server at svn.wp-plugins.org Port 80
403 Forbidden

Forbidden

You don't have permission to access /devformatter/branches/langs/autoconf.php on this server.


Apache Server at svn.wp-plugins.org Port 80
403 Forbidden

Forbidden

You don't have permission to access /devformatter/branches/langs/autoconf.php on this server.


Apache Server at svn.wp-plugins.org Port 80
403 Forbidden

Forbidden

You don't have permission to access /devformatter/branches/langs/autoconf.php on this server.


Apache Server at svn.wp-plugins.org Port 80
403 Forbidden

Forbidden

You don't have permission to access /devformatter/branches/langs/autoconf.php on this server.


Apache Server at svn.wp-plugins.org Port 80
403 Forbidden

Forbidden

You don't have permission to access /devformatter/branches/langs/autoconf.php on this server.


Apache Server at svn.wp-plugins.org Port 80
403 Forbidden

Forbidden

You don't have permission to access /devformatter/branches/langs/autoconf.php on this server.


Apache Server at svn.wp-plugins.org Port 80
403 Forbidden

Forbidden

You don't have permission to access /devformatter/branches/langs/autoconf.php on this server.


Apache Server at svn.wp-plugins.org Port 80
403 Forbidden

Forbidden

You don't have permission to access /devformatter/branches/langs/autoconf.php on this server.


Apache Server at svn.wp-plugins.org Port 80
403 Forbidden

Forbidden

You don't have permission to access /devformatter/branches/langs/autoconf.php on this server.


Apache Server at svn.wp-plugins.org Port 80
403 Forbidden

Forbidden

You don't have permission to access /devformatter/branches/langs/autoconf.php on this server.


Apache Server at svn.wp-plugins.org Port 80
403 Forbidden

Forbidden

You don't have permission to access /devformatter/branches/langs/autoconf.php on this server.


Apache Server at svn.wp-plugins.org Port 80

I tested this in Ubuntu 13.04, but essentially this should work in any Ubuntu distribution. First install the libtool, autoconf, automake, uuid-dev, e2fsprogs packages.

  |  copy code |? 
1
sudo apt-get install libtool autoconf automake uuid-dev e2fsprogs

Then clone the 0mq source using,

  |  copy code |? 
1
git clone git://github.com/zeromq/libzmq.git

Then go in to the libzmq directory and run the following commands in order.

  |  copy code |? 
1
./autogen.sh
2
./configure
3
make
4
sudo make install
5
ldconfig -v

Then run the following command and check the output.

  |  copy code |? 
1
ls -al /usr/local/lib/libzmq.*

The output should be similar to,

  |  copy code |? 
1
-rw-r--r-- 1 root root 7082022 ජූනි 7 14:16 /usr/local/lib/libzmq.a
2
-rwxr-xr-x 1 root root 947 ජූනි 7 14:16 /usr/local/lib/libzmq.la
3
lrwxrwxrwx 1 root root 15 ජූනි 7 14:16 /usr/local/lib/libzmq.so -> libzmq.so.3.0.0
4
lrwxrwxrwx 1 root root 15 ජූනි 7 14:16 /usr/local/lib/libzmq.so.3 -> libzmq.so.3.0.0
5
-rwxr-xr-x 1 root root 2876918 ජූනි 7 14:16 /usr/local/lib/libzmq.so.3.0.0

Now you should install the Java bindings for 0mq (in order to use omq from Java of course!). First check whether the JAVA_HOME environment variable is correctly set using,

  |  copy code |? 
1
echo $JAVA_HOME

This should output the location that you have installed Java. If it’s giving an empty output, then set it manually using

  |  copy code |? 
1
export JAVA_HOME=/<!--DVFMTSC-->location/to/your/java/installation<!--DVFMTSC-->
2

In my case the command is,

export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_17

Then clone the java bindings for 0mq using,

  |  copy code |? 
1
git clone https://github.com/zeromq/jzmq.git

now go inside the jzmq folder. Now same as before, run the following commands in order.

  |  copy code |? 
1
./autogen.sh
2
./configure
3
make
4
sudo make install

Now run the following command to verify the installation.

  |  copy code |? 
1
ls -al /usr/local/lib/*jzmq* /usr/local/share/java/*zmq*

The output should be like the following.

  |  copy code |? 
1
-rw-r--r-- 1 root root 535266 ජූනි 7 14:40 /usr/local/lib/libjzmq.a
2
-rwxr-xr-x 1 root root 998 ජූනි 7 14:40 /usr/local/lib/libjzmq.la
3
lrwxrwxrwx 1 root root 16 ජූනි 7 14:40 /usr/local/lib/libjzmq.so -> libjzmq.so.0.0.0
4
lrwxrwxrwx 1 root root 16 ජූනි 7 14:40 /usr/local/lib/libjzmq.so.0 -> libjzmq.so.0.0.0
5
-rwxr-xr-x 1 root root 242784 ජූනි 7 14:40 /usr/local/lib/libjzmq.so.0.0.0
6
-rw-r--r-- 1 root root 40618 ජූනි 7 14:40 /usr/local/share/java/zmq.jar

Notice the last line, that’s the newly created jar that connects to 0mq. Now you can use 0mq inside a Java programme.

Troubleshooting

If you get any of the following errors (which I got) when building the jar, export the mentioned system variables in the terminal to resolve them.

error

checking for javah… no

configure: error: cannot find javah

solution

  |  copy code |? 
1
export JAVAH=/<!--DVFMTSC-->location/to/your/java/installation/bin/javah

ex – export JAVAH=/usr/lib/jvm/jdk1.7.0_17/bin/javah

error

checking for jar… no

configure: error: cannot find jar

solution

  |  copy code |? 
1
export JAR=/location/to/your/java/installation/bin/jar
2

ex – export JAR=/usr/lib/jvm/jdk1.7.0_17/bin/jar

(Most of the content of this guide is based up on https://github.com/mslinn/zeromq-demo#ubuntu )

Share Button
Oct 09

My presentation on the internship at WSO2

This is the presentation I did after completing 5 months of internship in WSO2.  

Share Button
Sep 09

How I “earned” a Google Summer of Code project…!

It’s not a sin to try, the real sin is not trying at all should have been the thought that was working on my head in the months of March and April 2011, in the time that I was working hard to find a project in Google Summer of Code 2011, as a 2nd year student in the department of Computer Science and Engineering, University of Moratuwa. So after spending lot’s of time, I found a project that matched my novice knowledge. It was a project by a company called Digital Mars. The project idea in which I had interest (rather, I had the capability to work on) was “adding more containers to D”. In simple terms, what I had to do was to write new data structures to the programming language named D. I had never before heard about D or the data structures that they wanted to be implemented. But that didn’t stop me from trying. Countless hours were spent on learning D and learning about the data structures that they suggested. 

Unfortunately, being an organization which was in it’s debut GSoC, Digital Mars didn’t get many slots for their projects and they could only select the most critical projects to their product. So my project was not among the projects they selected for GsoC. But I felt really satisfied because I knew that if my project was selected, I had a very high chance of getting that project. Also my bond towards the internals of the Programming Languages kept growing because of the efforts I put for GsoC 2011 and that lead me to study more about Programming Languages in the university also (which showed me a total new path for my future carrier). So ultimately, my failure at GsoC 2011 was not a failure, but an achievement.

Time flew and came the time for the 3rd year Software Engineering Project (SEP) in the university. The visionary lecturers at our department wanted all 100 of the batch to find a way to contribute to a FOSS product (which would ultimately be the 3rd year SEP). The only exception they allowed other than contributing to a FOSS product is developing a mobile application. So in that sense, SEP is also like a mini-GSoC!.

The project idea that I came up with was writing a LibreOffice extension which allows the user to access their Google documents using the online accounts feature in Gnome 3. If you want more information about the product, please feel free to visit https://github.com/ishanthilina/Gnome-Online-Documents-Manager and view its documentation plus the crappy code it contains(yes, I admit, it contains crappy code!). Before starting the project, I had never written a single extension for LibreOffice nor even seen its API(or the Google API for Google Docs). It’s only after starting the project that I got to know the real pain of the trouble that I’ve put my self in to. There were only a handful of tutorials on writing LibreOffice extensions using Python (yes, I was going to code in Python, with no prior extensions knowledge!). And none of them described most of the essential parts that I needed to know about extensions developing under LibreOffice. And to make my matters worse, the documentation for the Google Docs API was not up to date with the Python Gdata library I used. Result..? 3 months of pure suffering!. At the end of the SEP evaluations, I knew that I am never going to write a LibreOffice extension again, I was simply had enough!.

In no time came GsoC 2012 and I was wandering through the ideas list again!. Seeing the number of Android projects available for this years GsoC, I blamed my self for not doing an Android related project. If I did so, my life would have been easier in the period of SEP and I could have easily found an Android project in GsoC. But hoping to find a project that suits me, I kept wandering through the GsoC 2012 ideas list, and BANG…!. I spotted a project on which the task was to write an extension to LibreOffice. The project was from the organization Creative Commons and the task was to port an existing LibreOffice extension to Python and add some more new features to it.

As you might have guessed, the first stream of thoughts that came up in to my mind were the bad memories of all the hardships which I had to undergo in SEP!. But I was not ready to give up that easily. So about a week before the deadline for the student application period I started communicating with the projects potential mentors on their mailing list. Finally I put an application for the proposal in Google Melange and when the selected students were announced, I was selected to that project!.

 It’s amazing how you can succeed when you keep trying even when you fail. You never fail until you abandon trying. Unlike in GsoC 2011,in GsoC 2012, I was able to get my hands on a project without trying much hard!.

But then came the most challenging days of the story. I knew that I had a lot to learn, and I knew that I had to learn fast!. I knew only a very little on extensions developing under LibreOffice. I didn’t know how to package an extension, I didn’t know how to write GUI stuff, I didn’t know how to debug in Python(yes, I was a complete novice to Python too!), and the list of I don’t knows seemed pretty endless!. Lot’s of time was spent on reading Java code (since most of the examples for LibreOffice extensions development was in Java) and another considerable amount of time was spent on porting that code to Python, lot’s of time was spent on learning new stuff.  

Since my internship in WSO2 had begun on those days, I was spending most of my time in WSO2. It was around 8.30-9pm everyday when I returned home . So I had only a little time to work on my GsoC project at night. But I didn’t give up. I managed to allocate at least an hour to the project everyday. And on weekdays, I spent lot’s of time on the project. They sure were hard days. Pretty hard indeed. But when the mid-term reviews were approaching, I truly was happy and progress seemed truly promising. I knew that I had learned a lot and I had done a pretty good job. My hard work had showed promising results. It was truly a satisfactory feeling.

And I should specially appreciate the support from my mentor,  Jonathan.Palecek. He always put faith on me, always motivated me to do my best, but at the same time didn’t expect me to be working like a slave, he was always this cool person who always put trust on me.

 Also I should give a special thank to Hanya. Without him, I won’t even make it to the mid-evaluations. He answered almost all of the questions I posted in OOoForum.org. I know at most of the times I was causing him lot’s of trouble and I really am thankful to him the way he tolerated all of them and how he always helped me in his full capacity.

 After the mid-term evaluations, life was much easier. I added some new features to the extension and ultimately I passed the final evaluation which resulted in a happy mentor, happy community and a happy student!. 

It’s amazing how the bitter experiences we undergo results in the sweetest memories in our lives. When the life puts challenges in front of us, we should make use of them, hence the same challenges will make our lives a comfortable place in the future. We should not be backing down in the face of difficulties hence the same difficulties will make our lives a luxurious place one day. All we need to master are patience and smart work!.

Always keep in mind, It’s not a sin to try, the real sin is not trying at all…!.

Share Button