Installing RxJava to Your Eclipse Project

Installing RxJava (Using Maven the Hard Way)

I’ve recently been looking into reactive Java programming. Problem is, it’s been ages since I’ve used eclipse and I’ve never really used Maven. So in short I had a hell of a time installing RxJava library working on my eclipse project.

Before I get a bunch of comments saying, “This isn’t Android programming”, “Where’s the IoT aspect?”, let me explain. Reactive programming is available to Android and will be a great way of creating event driven apps for the Internet of Things.

All of the directions I saw on installing RxJava involved using tools for resolving dependencies but didn’t show how to use them. I Googled it quickly and couldn’t find an obviously answer. So what now, cram it into your project duffel bag style.

First things first, you’ll need to create a new Maven Project.

Maven project highlighted

Next select the simple project checkbox and click Next.

highlighted simple type project checkbox

Final step creating the Maven project you’ll need to come up with a group and artifact id. Given the image below you should be able to come up with something, or feel free to follow along. This step isn’t crucial to the example.

maven project group and artifact information

This is where I decided to go the hard route. When adding a dependency my search was not populating any results. Because of this I assumed it just couldn’t find the file so I manually entered the dependency information.

Open up the pom.xml file and click on the “Dependencies” tab. Add a dependency by clicking the add button. Here you’ll be given the option to add the dependencies groupid, artifactid and version number. The other option, which didn’t work when I tried it so I assumed my dependency was unknown to maven it to use the bottom text field as a keyword search.

installing rxjava dependency properties

So use the search if it works for you, it will be much easier. If you happen to be unlucky like me you can continue this uphill battle with me to finish adding the dependency.

The fun continues…

After adding the dependency have a look at the package explorer. You’ll see under Maven Dependencies that there is a path next to the .JAR where the dependency should be, but it’s not… You’ll want to download that version of your dependency manually and copy it to that directory.

Right-click your project and refresh. Now try adding an object that exists in that library. For RxJava we can use the observable object. Be sure not to import the java.util version!

import rx.Observable;

Hopefully this helps some people. If you have anything to add please feel free to comment.

Leave a Reply

Your email address will not be published. Required fields are marked *