The general method installs Java JDK on a Windows environment.

Configure JDK

Download JDK

  1. Google Search "oracle jdk download"

google-search-jdk-download-page.png

  1. Open Oracle JDK download page

image-20221015155309872

  1. Select Windows if you are using a windows machine. Then, download the x64 Installer file.

image-20221015155809532

Check whether the installer was damaged

  1. Click sha256

image-20221015160740158

  1. You will get some random letters and numbers, like this

    4f66bf2c67aee5c0f2ed148086b257ddc4fad29c4c18b31f8ae85a93e8e7da8f
  2. Find your file, and copy the installer file path, NOT the installer itself
  3. Using keyboard shortcut, Win + R , then type cmd, hit enter to open the command prompt

image-20221015161743448

  1. Using the formula below to output the sha256 value of your downloaded installer file

    certutil -hashfile [Your file path] SHA256

    Example:

    certutil -hashfile C:\Users\danni\Downloads\jdk-19_windows-x64_bin.exe SHA256

image-20221015162601429

  1. Check if the sha 256 output value in the command prompt is the same as the website provided. If not, your file is damaged, please delete the installer file and re-download it again!

Start Installing

  1. Double click the jdk-19_windows-x64_bin.exe file

image-20221015163040463

  1. Click next, and remember the installation path

image-20221015163214278

  1. Click next. Then, close the installer.

image-20221015163513114

Check whether your JDK successfully installed in your machine

  1. Using the keyboard shortcut, Win + R , then type cmd, hit enter to open the command prompt
  2. type command

    java -version
  3. If you received any output like this below, you are good to go

    C:\Users\danni>java -version
    java version "19" 2022-09-20
    Java(TM) SE Runtime Environment (build 19+36-2238)
    Java HotSpot(TM) 64-Bit Server VM (build 19+36-2238, mixed mode, sharing)

    If you received any output like this below, the JDK may be partially installed. You may need to configure system environment variables manually.

    C:\Users\danni>java -version
    'java' is not recognized as an internal or external command.

Configure environment variables

You can simply skip this step if you installed your JDK successfully.
  1. For windows 11, go to Settings --> System --> About

image-20221015165909633

  1. Click Advanced system settings

image-20221015170027225

  1. Click Environment Variables

image-20221015170241231

  1. Add/Edit the following System variables

    Variable name: JAVA_HOME
    Variable value: C:\Program Files\Java\jdk-19 //This is your actual installation path
    
    Variable name: Path
    Variable value: %JAVA_HOME%\bin
    
    Variable name: Path
    Variable value: %JAVA_HOME%\jre\bin

Using Code Editor

In order to edit your code locally, you need to install code editor software on your machine.

If you are using Linux based operating system and you are familiar with terminal commands, you can use nano, vi, vim, or emac. We will not discuss the Linux terminal environment here.

If you are using a Windows operating system. You can use any editor your like, for example, VS Code, Notepad, or Notepad++. I personally recommend VS Code.

image-20221028163027016

To create a new file:

Select File >> New File

image-20221028163153576

Then, type your file name here. (Please include your file extension name)

image-20221028163346934

Finally, select the path that you want to save your file.

Run Your Code

  1. Save the code below and named it as test.java

    import java.util.Date;
    
    public class test {
        public static void main(String[] args) {
            System.out.println("Current Time: " + getTime());
            System.out.println("Congratulation, your Java has been successfully run locally.");
        }
    
        public static String getTime() {
            Date date = new Date();
    
            return date.toString();
        }
    }
  2. Using the keyboard shortcut, Win + R , then type cmd, hit enter to open the command prompt
  3. Using javac to compile your .java file
    For example:

    C:\Users\danni\Downloads>javac test.java
  4. Then, the compiler will generate a .class file. This file is intended to be run.
  5. Using java command to run your file
    For example:

    C:\Users\danni\Downloads>java test
    Notes: This is just an example, and you need go to your test.java directory in order to run your java file!

image-20221015173048788

TOC