- RxJava - Discussion
- RxJava - Useful Resources
- RxJava - Quick Guide
- RxJava - Windowing
- RxJava - Buffering
- RxJava - From Scheduler
- RxJava - IO Scheduler
- RxJava - Computation Scheduler
- RxJava - NewThread Scheduler
- RxJava - Trampoline Scheduler
- RxJava - Schedulers
- RxJava - AsyncSubject
- RxJava - ReplaySubject
- RxJava - BehaviorSubject
- RxJava - PublishSubject
- RxJava - Subjects
- RxJava - Connectable Operators
- RxJava - Mathematical Operators
- RxJava - Conditional Operators
- RxJava - Utility Operators
- RxJava - Combining Operators
- RxJava - Filtering Operators
- RxJava - Transforming Operators
- RxJava - Creating Operators
- RxJava - Using CompositeDisposable
- RxJava - Completable Observable
- RxJava - MayBe Observable
- RxJava - Single Observable
- RxJava - Creating Observables
- RxJava - How Observable works
- RxJava - Environment Setup
- RxJava - Overview
- RxJava - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
RxJava - Environment Setup
Local Environment Setup
RxJava is a pbrary for Java, so the very first requirement is to have JDK installed in your machine.
System Requirement
JDK | 1.5 or above. |
---|---|
Memory | No minimum requirement. |
Disk Space | No minimum requirement. |
Operating System | No minimum requirement. |
Step 1 - Verify Java Installation in Your Machine
First of all, open the console and execute a java command based on the operating system you are working on.
OS | Task | Command |
---|---|---|
Windows | Open Command Console | c:> java -version |
Linux | Open Command Terminal | $ java -version |
Mac | Open Terminal | machine:< joseph$ java -version |
Let s verify the output for all the operating systems −
OS | Output |
---|---|
Windows | java version "1.8.0_101" Java(TM) SE Runtime Environment (build 1.8.0_101) |
Linux | java version "1.8.0_101" Java(TM) SE Runtime Environment (build 1.8.0_101) |
Mac | java version "1.8.0_101" Java(TM) SE Runtime Environment (build 1.8.0_101) |
If you do not have Java installed on your system, then download the Java Software Development Kit (SDK) from the following pnk
. We are assuming Java 1.8.0_101 as the installed version for this tutorial.Step 2 - 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 FilesJavajdk1.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 FilesJavajdk1.8.0_101in at the end of the system variable, Path. |
Linux | export PATH = $PATH:$JAVA_HOME/bin/ |
Mac | not required |
Verify Java installation using the command java -version as explained above.
Step 3 - Download RxJava2 Archive
Download the latest version of RxJava jar file from
and its dependency . At the time of writing this tutorial, we have downloaded rxjava-2.2.4.jar, reactive-streams-1.0.2.jar and copied it into C:>RxJava folder.OS | Archive name |
---|---|
Windows | rxjava-2.2.4.jar, reactive-streams-1.0.2.jar |
Linux | rxjava-2.2.4.jar, reactive-streams-1.0.2.jar |
Mac | rxjava-2.2.4.jar, reactive-streams-1.0.2.jar |
Step 4 - Set RxJava Environment
Set the RX_JAVA environment variable to point to the base directory location where RxJava jar is stored on your machine. Let’s assuming we ve stored rxjava-2.2.4.jar and reactive-streams-1.0.2.jar in the RxJava folder.
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 |
Step 5 - Set CLASSPATH Variable
Set the CLASSPATH environment variable to point to the RxJava jar location.
Sr.No | OS & Description |
---|---|
1 | Windows Set the environment variable CLASSPATH to %CLASSPATH%;%RX_JAVA% xjava-2.2.4.jar;%RX_JAVA% eactive-streams-1.0.2.jar;.; |
2 | Linux export CLASSPATH = $CLASSPATH:$RX_JAVA/rxjava-2.2.4.jar:reactive-streams-1.0.2.jar:. |
3 | Mac export CLASSPATH = $CLASSPATH:$RX_JAVA/rxjava-2.2.4.jar:reactive-streams-1.0.2.jar:. |
Step 6 - Test RxJava Setup
Create a class TestRx.java as shown below −
import io.reactivex.Flowable; pubpc class TestRx { pubpc static void main(String[] args) { Flowable.just("Hello World!").subscribe(System.out::println); } }
Step 7 - Verify the Result
Compile the classes using javac compiler as follows −
C:RxJava>javac Tester.java
Verify the output.
Hello World!Advertisements