How to setup JDK in your machine?

 Here are the steps to install JDK and set the JAVA_HOME environment variable in Windows, macOS, and Linux:

Windows:

  1. Go to the official Java website (https://www.java.com/) and download the JDK installer for Windows.
  2. Run the installer and follow the prompts to install JDK on your computer.
  3. Open the Start menu, search for "Environment Variables" and select "Edit the system environment variables"
  4. Click on the "Environment Variables" button.
  5. Under "System Variables", scroll down and find the "JAVA_HOME" variable. Click "New" to create the variable if it doesn't already exist.
  6. Set the value of the JAVA_HOME variable to the directory where the JDK is installed. For example, "C:\Program Files\Java\jdk-14"
  7. Click "OK" to save the changes.
  8. Go to the "Path" variable under "System Variables" and click "Edit".
  9. Click "New" and add the "bin" folder of JDK installation to the path. for example, "%JAVA_HOME%\bin"
  10. Click "OK" to save the changes.


macOS and Linux:

  1. Go to the official Java website (https://www.java.com/) and download the JDK installer for macOS or Linux.
  2. Run the installer and follow the prompts to install JDK on your computer.
  3. Open the Terminal and type the following command:
    export JAVA_HOME=path/to/jdk (replace path/to/jdk with the directory where the JDK is installed)
  4. Type the following command to add the JDK to your PATH:
    export PATH=$PATH:$JAVA_HOME/bin

To make the environment variable changes permanent, you will need to add the above two commands to your shell profile file, such as .bash_profile or .bashrc depending on your shell.

To verify that the JDK and JAVA_HOME environment variable are set up correctly, you can open a command-line prompt and type "java -version". This should display the version of the JDK that is currently installed and the path should match with the one you set.

Comments

Popular posts from this blog

Getting Started with the Java Flow API

Loops in Java 8

switch case in java