Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

class file for org.reactivestreams.Publisher not found while compiling example from RxJava?

The following code

package com.inthemoon.snippets.rxjava;

import io.reactivex.*;

public class HelloWorld {

   public static void main(String[] args) {
      Flowable.just("Hello world").subscribe(System.out::println);
   }

}

causes the following compile error

Error:(9, 15) java: cannot access org.reactivestreams.Publisher class file for org.reactivestreams.Publisher not found

POM dependency is following

<dependencies>
        <!-- https://mvnrepository.com/artifact/io.reactivex.rxjava2/rxjava -->
        <dependency>
            <groupId>io.reactivex.rxjava2</groupId>
            <artifactId>rxjava</artifactId>
            <version>2.0.4</version>
        </dependency>


    </dependencies>
like image 855
Dims Avatar asked Jan 24 '17 08:01

Dims


3 Answers

Same error and simple solution - add this to your app Gradle file

implementation 'io.reactivex.rxjava2:rxjava:2.1.14'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
like image 123
Ivan Vovk Avatar answered Nov 13 '22 14:11

Ivan Vovk


The same happened to me.I have solved it. add the dependeny follows:

<dependency>
    <groupId>org.reactivestreams</groupId>
    <artifactId>reactive-streams</artifactId>
    <version>1.0.0</version>
</dependency>
like image 4
KingJA Avatar answered Nov 13 '22 13:11

KingJA


This has been fixed since 2.0.5 by github.com/ReactiveX/RxJava/issues/5014 2.1.1, is the latest version as of this answer

Solution :

    <dependency>
        <groupId>io.reactivex.rxjava2</groupId>
        <artifactId>rxjava</artifactId>
        <version>2.1.1</version>
    </dependency>
like image 4
Laurent Perez Avatar answered Nov 13 '22 15:11

Laurent Perez