local environment setup
rxjava is a library 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 link https://www.oracle.com. 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 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 |
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 rxjava @ mvnrepository and its dependency reactive streams @ mvnrepository . 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%\rxjava-2.2.4.jar;%rx_java%\reactive-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; public class testrx { public 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!