How to set JAVA HOME path via the command line

preview_player
Показать описание
#javahome #javatips
How to set JAVA HOME path via the command line
How to set JAVA HOME variable via the command line

Hey! Setting the `JAVA_HOME` path on Windows is a piece of cake. Here's a quick step-by-step:

1. **Find your Java installation directory:**
Usually, it's in `C:\Program Files\Java`. Look for a folder like `jdk1.x.x` (the version number).

2. **Copy the path to the Java installation directory.**

3. **Set the `JAVA_HOME` environment variable:**

- Set the value of the environment variable to your JDK (or JRE) installation path as follows:

setx /m JAVA_HOME "C:\Program Files\Java\jdk11.0.17.8"

- Right-click on "This PC" or "Computer" on your desktop or in File Explorer."
- Select "Properties. Click on "Advanced system settings" on the left.
- Click the "Environment Variables" button.
-Press enter in cmd. Restart Command Prompt to reload the environment variables then use the following command to check the it's been added correctly.
- echo %JAVA_HOME%.
- Click "OK" to close the dialogs.

4. **Update the `Path` environment variable:**
- In the same "Environment Variables" window, find the "Path" variable in the "System variables" section and select it.
- Click "Edit."
- Click "New" and add `%JAVA_HOME%\bin` to the list.
- Click "OK" to close the dialogs.

5. **Verify the setup:**
- Open a new Command Prompt window.
- Type `java -version` and press Enter. You should see information about your Java version.
Рекомендации по теме