JDK Installation guide for Windows { With Example }

The Java Development Kit (JDK) OR "Java Platform, trendy version (Java SE)" is available for writing Java applications. The JDK is freely available from sun Microsystems (now part of Oracle). The official website for JDK (Java SE) is oracle.com


What is  "JDK" or "JRE" ?

JRE (Java Runtime) is used to running Java programs. JDK (Java Development Kit) comes with JRE plus the development tools (such as compiler and debugger), is need for writing (developing) as well as running Java programs. In other words, JRE is a subset of JDK. So you should install JDK with JRE to develop java applications.
 

1.  How To Install JDK on Windows

Note : Please Uninstall the Older Virsion of JDK/JRE

Step 1A : Download The Setup of JDK

  1. Click the link to go to download page Download Setup
  2. Choose the right version of JDK for your operating system and download the setup file (JDK Installer)

Step 1B: Installation

Run the downloaded setup file, which installs both the JDK and JRE. 
Accept the defaults and follow the screen instructions to install JDK and JRE.

Step 1C: Creating Environment Variable (JAVA_HOME)

  1. locate your java installation directory

    If you didn't change the path during installation, it'll be something like 
    C:\Program Files\Java\jdk-17

    You can also find a path through CMD with this comand : where java

  2. Windows 7 – Right click My Computer and select Properties > Advanced
    Windows 8 – Go to Control Panel > System > Advanced System Settings
    Windows 10 – Search for Environment Variables then select Edit the system environment variables

  3. Under "System Variables", scroll down and select "Path" then Click on "Edit..."
  4. In the "Variable value" field, insert this line

    "c:\Program Files\Java\jdk-x\bin"

    NOTE: Replace x with your setup version,
     for example : jdk-9.0.1 or jdk-17

Step 1D: Verify JDK Installation

  1. Launch CMD
  2. Write javac then press enter
  3. If there is no error message, it means you have successfully installed JDK

2.  Hello World Example in java                                                                                       

Now we are ready to create our first java program. we will create the hello world program as an example. 

Steps
  1. Open notepad
  2. Copy code from below and paste in notepad

    Script For Hello.java Fileclass Hello{
         public static void main(String args[]){
         System.out.println("Hello World");
       }
    }
  3. Now save the file as Hello.java
    Note: File name and class name must be the same, the first letter of file name and class name should be capitalized.
  4. Now open CMD and write commands as step 5 and 6 to compile this java program then execute to see the result.
  5. Now compile => javac Hello.java
  6. Then execute => java hello
The output should be like this



Here is a video tutorial



Comments