In previous chapter we have learnt about JVM, JRE, JDK. Now let's setup environment for java development. There are two steps:
You can downlaod latest version of JDK ie. JDK 8, from following link Java SE Development Kit
Java SE(Standard Edition)is freely available on oracle's official website. Go to above link then accept license agreement and then select to download suitable version based on your operating system and it's architecture(32bit/64bit).
If you want to check your OS architecture(32bit/64bit) then you can find it by executing "systeminfo" command on windows command prompt or "arch" command on linux shell.
We need to set environment variable named "PATH" pointing to JDK's bin directory, so that we can access JDK's tools(java, javac...) from any directory by it's name(without giving full path).
Follow below steps to set path environment variable in windows.
C:\windows\system32;C:\Program Files\Java\jdk1.8.0_121\bin;(Change according to your java installation path)
C:\Program Files\Java\jdk1.8.0_121\bin(change as per path in your system).
In linux we use export command to set path. We can set temporary path using following command.
For setting up path permanently, open .profile file present in your home directory or if not present then create new file named ".profile" and open. Now paste following code at the last line
export PATH=$PATH:/home/jdk1.8.0_121/bin/ (change path according to your java installation path) and save the file.
Simply open command prompt and check by running commands "java" and "javac" one bye one. If you are getting java options in output then it's correct otherwise you will get following error
'java' is not recognized as an internal or external command, operable program or batch file.
In next chapter you will learn how to compile and run your first java program