Java – Greenrobot’s EventBus on normal Java applications

Greenrobot’s EventBus on normal Java applications… here is a solution to the problem.

Greenrobot’s EventBus on normal Java applications

I’ve been developing Android apps and I’ve been using Greenrobot EventBus, you can find it here, I really like it. Simple, versatile, and easy to use.

Now I’m creating a Java application that would help me if I used an event bus. So I thought about using Greenrobot EventBus but then it was made for Android and I’m not sure if there were any issues when using it with normal Java Application, after all, they are all Java.

I

know of other event bus libraries such as Guava and Akka, but since I’m already familiar with Greenrobot EventBus and it’s very flexible in terms of multithreading (which helps me too), I’m thinking about using Greenrobot and saving some time.

Solution

I’ve tried using this library in normal Java projects (version 2.4.0, last stable release).
It seems impossible to use it due to Android dependencies.

import de.greenrobot.event.EventBus;

public class MainTest {
    EventBus eventBus = EventBus.getDefault();

eventBus.post("This is a test event object");
}

ClassNotFoundException is triggered:

error screenshot

P.S.: I didn’t try version 3.0.0-beta1.

Related Problems and Solutions