RxJava - Environment Setup

RxJava - Environment Setup

RxJava is java library. TO work with RxJava we need first Java.

Environment Setup

Verify Java Installation

Open the console and execute a java command
 

Windows  -> c:\> java -version

Linux  -> $ java -version

Mac  -> machine:< joseph$ java -version

 

It will returns java version if it installed.

If you do not have Java installed on your system, then download the Java Software Development Kit (SDK) from the following link https://www.oracle.com. We are assuming Java 1.8.0_101 as the installed version for this tutorial

 

Set JAVA Environment

Set the JAVA_HOME environment variable to point to the base directory location where Java is installed on your machine. For example

OS Output
Windows Set the environment variable JAVA_HOME to C:\Program Files\Java\jdk1.8.0_101
Linux export JAVA_HOME = /usr/local/java-current
Mac export JAVA_HOME = /Library/Java/Home

Append Java compiler location to the System Path.

OS Output
Windows Append the string C:\Program Files\Java\jdk1.8.0_101\bin at the end of the system variable, Path.
Linux export PATH = $PATH:$JAVA_HOME/bin/
Mac not required

 

Download RxJava2 

Download the latest version of RxJava jar file from RxJava @ MVNRepository and its dependency Reactive Streams @ MVNRepository . At the time of writing this tutorial, we have downloaded rxjava-2.2.19.jar, reactive-streams-1.0.3.jar

 

Set RxJava Environment

Sr.No OS & Description
1

Windows

Set the environment variable RX_JAVA to C:\RxJava

2

Linux

export RX_JAVA = /usr/local/RxJava

3

Mac

export RX_JAVA = /Library/RxJava

 

Set CLASSPATH Variable

Sr.No OS & Description
1

Windows

Set the environment variable CLASSPATH to %CLASSPATH%;%RX_JAVA%\rxjava-2.2.19.jar;%RX_JAVA%\reactive-streams-1.0.3.jar;.;

2

Linux

export CLASSPATH = $CLASSPATH:$RX_JAVA/rxjava-2.2.19.jar:reactive-streams-1.0.3.jar:.

3

Mac

export CLASSPATH = $CLASSPATH:$RX_JAVA/rxjava-2.2.19.jar:reactive-streams-1.0.3.jar:.

 

Verify RxJava by simple Example

public class RXJava {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
       Observable<String> observer = Observable.just("Hello RxJava"); // provides datea
        observer.subscribe(s -> System.out.println(s));
    }
    
}

Output

Hello RxJava

 

*

RxJava Tutorial RxJava - Environment Setup RxJava’s Characteristics RxJava - How Observable works RxJava - Single Observable RxJava - MayBe Observable RxJava - Completable Observable RxJava - Using CompositeDisposable RxJava - Creating Operators RxJava - Transforming Operators RxJava - Filtering Operators RxJava - Combining Operators RxJava - Utility Operators RxJava - Conditional Operators RxJava - Mathematical Operators RxJava - Subjects RxJava - PublishSubject RxJava - BehaviorSubject RxJava - AsyncSubject RxJava - ReplaySubject RxJava - Schedulers RxJava - Trampoline Scheduler RxJava - NewThread Scheduler RxJava - Computation Scheduler RxJava - IO Scheduler RxJava - From Scheduler RxJava - Buffering