Java Installation

In previous chapter we have learnt about JVM, JRE, JDK. Now let's setup environment for java development. There are two steps:

  1. Download and install JDK
  2. Set the Path (for JDK's bin directory)

Download and Install JDK (Java Development Kit)

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.

Why Set Path?

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).

Set Path for Windows

Follow below steps to set path environment variable in windows.

  • Right-click on "my computer" then click on properties.
  • From left navigation click on "Advanced System Settings"
  • Now go to advanced tab, there click on "environment variables"
  • Check if variable named "Path" or "PATH" is already present, if yes then append your JDK's bin directory path. For example if current value of Path variable is "C:\windows\system32" then append like following C:\windows\system32;C:\Program Files\Java\jdk1.8.0_121\bin; (Change according to your java installation path)
  • And if variable named Path is not present then create new variable give name "Path"(without quotes) and value C:\Program Files\Java\jdk1.8.0_121\bin(change as per path in your system).

Set Path for Linux/Unix

In linux we use export command to set path. We can set temporary path using following command.
export PATH=$PATH:/home/jdk1.8.0_121/bin/

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.

How to Check Whether Path is Correctly Set or Not?

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.

Next Chapter

In next chapter you will learn how to compile and run your first java program