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