How to download, install, and configure JDK in an environment

This is the first tutorial, in our JAVA video tutorial series, where I am going to highlight the steps you need to follow in order to download, install, and configure JDK on your machine. This is kind of a pre-requisite step, in case you wish to code, and run Java based applications. We are certainly going to talk more about its usage and the reason why exactly should we have it, later in this tutorial series but for now just trust me on this and follow the below mentioned steps, you’ll be able to set-up JDK on you machine.

  1. Click on following link to perform a Google search: Download JDK
  2. Most probably you’ll end up on following page:
  3. You may see various options under JAVA Platform SE 7( Standard Edition) like JDK, Server JRE, and simply JRE. Click on the download link below JDK.
  4. Read and accept the license agreement and download the JDK package as per your environment [Windows/Linux/Mac/Solaris].
  5. Open the installer file and choose the default steps for easy installation.
  6. Now, we need to make sure that all the executable files under installation directory like java, javac, javah,javap, javaw, etc. are in the environment class-path.
  7. The advantage of adding files in an environment class-path is that we can access/read/execute these files just by their file-names from a terminal/console/command-prompt/IDE… and we don’t have to specify the full path of those files in order to execute them, they will be globally available to all the processes running on the environment. If we don’t add an executable file in the class-path then we have to specify the full-path of that file in order to execute them from a terminal/console/cmd…
  8. Sorry guys but right now this post is making me feel bored as hell so I’ll only cover how to configure JDK in a Windows environment, will update this post later to include Linux/Mac steps.
  9. Windows: How to add JAVA files in environment class-path:
    • Right click on ‘My Computer’ >> Properties >> Advanced system settings >> System Properties window will open-up
    • Go to Advanced tab >> Environment Variables… >> System variables section>> Click on New… button
    • Set Variable name: JAVA_HOME and provide Variable value: as your local path of the JDK installation directory. e.g: C:\Program Files\Java\jdk1.7.0_15 
    • %JAVA_HOME% directory usually contains following sub-directories: bin, include, jre, lib, etc. It also contains a file which contains the source code of core jars related to Java like %JAVA_HOME%\jre\lib\rt.jar, etc..
    • %JAVA_HOME%\bin directory contains all the java executable files so it should be present in the class-path for easier access
    •  Go back to System variables section >> Scroll-down and open the Path variable for editing
    •  Copy the Path variable value in a Notepad for easier editing
    •  Add following text at the beginning of the original value: %JAVA_HOME%\bin;
    •  For e.g. If the old value looked something like abc;def;ghi;xyz; then new value should look like %JAVA_HOME%\bin;abc;def;ghi;xyz;
    •  Overwrite the Path environment variable value with the new value. Click on ‘OK’ button, wheresoever applicable.
    •  Open windows command prompt:: Open run prompt[Win-key + r], type cmd and hit enter
    •  Type echo %JAVA_HOME% hit enter to confirm that JAVA_HOME variable is set
    •  Type echo %PATH% hit enter to confirm that JAVA_HOME\bin directory is in environment PATH variable
    •  Type javac hit enter and examine the output. If it resembles like below image, then we are done.javac output
    •  You must have noticed above that we only wrote javac as a command, which is basically an executable file[*.exe] residing in JAVA_HOME\bin directory and we don’t have to specify the full path any more in order to execute it. Voila ! Thanks for reading.

Share your thoughts