To send errors to Rollbar from your Java application, you should use our rollbar-java package.



The minimal amount of code you need to use rollbar-java is:

import static com.rollbar.notifier.config.ConfigBuilder.withAccessToken;
import com.rollbar.notifier.Rollbar;
Rollbar rollbar = Rollbar.init(withAccessToken("{{ server_access_token }}"));
rollbar.log("Hello, Rollbar");

A few seconds after you execute this code, the message should appear on your project's "Items" page.

For a more detailed example integration, see below:

We initialize com.rollbar.notifier.Rollbar with a Config which has the access token and other configuration properties set on it. We can then this this instance of Rollbar to report messages via the log/debug/warning/error/critical methods.

Any uncaught exceptions are automatically reported to Rollbar. This behavior can be turned off via the configuration.

import static com.rollbar.notifier.config.ConfigBuilder.withAccessToken;
import com.rollbar.notifier.Rollbar;
import com.rollbar.notifier.config.Config;

public class Application {
  private Rollbar rollbar;

  public Application() {
    Config config = withAccessToken("{{ server_access_token }}")
    this.rollbar = Rollbar.init(config);

  public static void main(String[] args) {
    Application app = new Application();

  private void execute() {
    try {
      throw new RuntimeException("Some error");
    } catch (Exception e) {
      rollbar.error(e, "Hello, Rollbar");

A more full-featured example can be found on GitHub.


All configuration is done via the Config object in rollbar-java. You can see the interface here.


Check out this blog post for more information on how to use rollbar-java in your Spring app.