Add java to path windows 10

Для добавления пути к JDK (Java Development Kit) в переменную среды PATH в Windows, следуйте этим шагам:

  1. Откройте «Системные настройки» в Windows. Это можно сделать несколькими способами, например, нажав на клавишу Windows и искать «системные настройки» или нажав правой кнопкой мыши на значке «Этот компьютер» и выбрав «Свойства»
  2. В меню слева выберите «Дополнительные параметры системы»
  3. Нажмите на кнопку «Переменные среды» в нижней части окна.
  4. В разделе «Системные переменные» найдите переменную Path и выберите «Изменить»
  5. Нажмите на кнопку «Новый» _ и введите путь к JDK. Обычно это путь к папке _»bin» в установленной JDK, например: C:\Program Files\Java\jdk1.8.0_291\bin
  6. Нажмите «ОК» во всех открытых окнах, чтобы сохранить изменения.

После этого вы можете использовать команды java и javac в командной строке Windows из любого места в файловой системе.

In this post, we will see about how to set java path in windows 10 using cmd. To set java path, you need to first understand about JAVA_HOME and how to set JAVA_HOME in windows 10.

Let’s first understand about JAVA_HOME and then we will see how to set JAVA_HOME in windows 10.

What is JAVA_HOME?

JAVA_HOME is environment variable which contains installation directory of Java development kit(JDK) or Java Runtime environment(JRE). This environment variable is setup at operating system level.

JAVA_HOME=C:\Program Files\Java\jdk11.0.9

Why do you need JAVA_HOME?

JAVA_HOME environment variable points to directory where java is installed on your system, so many java based applications such as TOMCAT use JAVA_HOME environment variable to locate java executables.

How to set JAVA_HOME in Windows 10?

  1. Locate JDK on your machine.
    • If you are using 64-bit java, then it will be in C:\Program Files\Java\
    • If you are using 32-bit java, then it will be in C:\Program Files (x86)\Java\
  2. Open windows search, type environment and click on Edit the system environment variables.

    Edit environment variable in java

  3. In System properties dialog, go to Advanced tab and click on button Enviroment Variables.

    Click on Edit environment variable

  4. In System variables, click NEW... button to add JAVA_HOME environment variable.

    Add new environment variable

  5. Provide variable name as JAVA_HOME and value as Java installation directory.

    Set Java home environment variable

Now let’s see how to set java in path environment variable in windows 10.

  1. In System variable window, locate Path and click on Edit....

    Click on edit

  2. Double click on the empty row and add %JAVA_HOME%\bin.

    Set java path in windows 10

    Here, % symbol is used to locate JAVA_HOME environemt variable and \bin provides location for java.exe and h=javac.exe

  3. Close the command prompt and launch again.
  4. Check java version as below:

    Check java version

That’s all about How to set java path in windows 10.

Last Updated :
17 May, 2024

PATH is an environment variable that is used by Operating System to locate the exe files (.exe) or java binaries ( java or javac command). The path once it is set, cannot be overridden. The PATH variable prevents us from having to write out the entire path to a program on the Command Line Interface every time we run it. Moreover, the path is just a variable that stores a bunch of shortcuts.

To execute Java console-based programs in Windows or Linux environments, we have to use Java and javac commands. The commands java and javac are not known to the operating system as we don’t specify where the executables reside. Hence, we need to specify the path where the executables are located. This is the reason we set the path and specify the path of the bin folder because the bin contains all binary executable files. After setting the path, it can load all necessary items in the program including the compiler or interpreter itself. 

Below is the procedure for how to set Java Path in both Windows and Linux?

To Set Java Path in Windows

Step 1: Go to the Search box and type Advanced System settings in it. Now click on the View Advanced System settings.

to-set-java-path-in-windows

Step 2: Select the Advanced tab and then click environment variables.

Step 3: In the system, variables click the New button. Now in the edit System variable, type variable name as JAVA_HOME and variable path as the path where the JDK folder is saved and click on OK button Usually the path of the JDK file will be C:\Program Files\Java\jdk1.8.0_60.

Step 4: Now in the system variables go to the path and click the Edit button.

Step 5: Click the New button.

Step 6: Now add the following path: %JAVA_HOME%\bin

To Find Java Path in Windows:

Here are the simple steps to find your Java path in Windows:

Step 1: Open a Command Prompt window.

Type the following command and press Enter:

where java

Step 2: You should see the path to your Java installation printed in the Command Prompt. It will typically look something like this:

C:\Program Files\Java\jdk1.8.0_291\bin\java.exe

That’s it! You’ve found your Java path in Windows.

To Set Java Path in Linux

Follow the given steps to set Java Path in Linux —

  • Open the terminal and enter the following command: 
sudo nano /etc/environment.
  • A file will be opened and add the following command to that file:
JAVA_HOME = "YOUR_PATH". 
  • Replace YOUR_PATH with the JDK bin file path.
  • Now restart your computer or virtual machine that you are using (or) reload the file: source /etc/environment
  • You can test the path by executing
 echo $JAVA_HOME
  • If you get the output without any error, then you’ve set the path correctly.
  • If you get any errors, try repeating the procedure again.

To Find Java Path in Linux:

Here are the steps to find Java Path in Linux System —

Step 1: Open a Terminal window.

Step 2: Type the following command and press Enter:

which java

Step 3: You should see the path to your Java installation printed on the terminal. It will typically look something like this:

/usr/bin/java

That’s it! You’ve found your Java path in Linux.

Conclusion

So, this was all about how you can find and set Java path in Windows and Linux. If you also have other queries regarding setting Java Path, Java_Home variable and default Java path, You can also refer to the following frequently asked questions.

Setting the Java path in Windows 10 is an essential step for developers and users who rely on Java for their applications and software. With Java being one of the most widely used programming languages, ensuring the correct configuration of the Java path is crucial for smooth execution and functionality. Let’s explore the process of setting the Java path in Windows 10, simplifying the way Java applications are accessed and utilized.

To set the Java path in Windows 10, you need to begin by locating the Java Development Kit (JDK) installation folder on your system. Once you have identified the JDK folder, copy the path to the clipboard. Next, access the System Properties of your Windows 10 computer. There, you can navigate to the Advanced tab and click on the ‘Environment Variables’ button. Here, you will find a list of system variables. Locate the ‘Path’ variable and select ‘Edit.’ In the editable ‘Variable Value’ field, append a semi-colon at the end and paste the copied JDK path. Click ‘OK’ on all the windows, and you have successfully set the Java path in Windows 10.

Setting the Java path in Windows 10 is essential for executing Java applications seamlessly. Follow this step-by-step guide to configure the Java path:

  • Open the System Properties window by right-clicking on the «This PC» icon and selecting «Properties.»
  • Choose «Advanced System Settings» and click on «Environment Variables.»
  • In the System Variables section, locate the «Path» variable, and click «Edit.»
  • Add the path to the Java installation directory, ensuring it ends with «\bin».
  • Click «OK» on all windows to save the changes.

Now, your Java path is set in Windows 10, enabling Java applications to run smoothly.

How To Set Java Path In Windows 10

Introduction to Setting Java Path in Windows 10

Java is a popular programming language that is widely used for developing various applications. To run Java programs or compile code on your Windows 10 system, it is essential to properly set the Java path. The Java path refers to the location of the Java Development Kit (JDK) on your computer, which allows the operating system to locate and execute the Java commands. Setting the Java path correctly ensures that you can conveniently use Java for your programming needs.

Why Set the Java Path?

Setting the Java path in Windows 10 is necessary for several reasons:

  • Allows you to run Java applications and programs seamlessly on your computer.
  • Enables the Java compiler to find and execute Java commands.
  • Makes it easier to use various Java tools and libraries.
  • Ensures compatibility between different versions of Java installed on your system.

Now let’s explore the steps to set the Java path in Windows 10.

Checking Java Installation

Before setting the Java path, it is essential to ensure that Java is already installed on your Windows 10 system. Follow these steps to verify the Java installation:

  • Open the Command Prompt by pressing Windows Key + R, typing «cmd», and clicking «OK».
  • In the Command Prompt window, type «java -version» and press Enter.
  • If Java is installed, you will see the version information displayed. If Java is not found, you will need to download and install it from the official Java website.

Once you have confirmed the Java installation, you can proceed with setting the Java path.

Step 1: Locate the Java Installation Directory

The first step is to locate the directory where Java is installed on your Windows 10 system. By default, Java is typically installed in the «C:\Program Files\Java» directory. However, the exact path may vary depending on the Java version and installation options you selected.

Java Version Installation Directory
Java 8 C:\Program Files\Java\jdk1.8.0_x (x is the update number)
Java 11 C:\Program Files\Java\jdk-11

Note: If you have multiple versions of Java installed on your system, make sure to locate the desired version for setting the Java path.

Step 2: Open Environment Variables Settings

In order to set the Java path, you need to access the Environment Variables settings on your Windows 10 system. Follow these steps:

  • Right-click on the Start menu and select «System».
  • In the System window, click on «Advanced system settings» on the left-hand side.
  • In the System Properties dialog, click on the «Environment Variables» button.

By accessing the Environment Variables settings, you will be able to set the Java path for your Windows 10 system.

Step 3: Set the Java Path

Now, let’s proceed with setting the Java path in Windows 10:

  • In the Environment Variables window, under the «System variables» section, scroll down and locate the «Path» variable.
  • Select the «Path» variable and click on the «Edit» button.

Editing the «Path» variable allows you to add the Java installation directory to the system’s path.

Step 4: Add the Java Installation Directory to the Path

To add the Java installation directory to the system’s path, follow these steps:

  • In the «Edit Environment Variable» window, click on «New» to add a new entry.
  • In the «Variable value» field, enter the path to the Java installation directory. For example:
    • C:\Program Files\Java\jdk1.8.0_x\bin (for Java 8)
    • C:\Program Files\Java\jdk-11\bin (for Java 11)
  • Click «OK» to save the changes.
  • Close all the open Command Prompt windows.

By adding the Java installation directory to the system’s path, you have successfully set the Java path on your Windows 10 system.

Step 5: Verify the Java Path

To ensure that the Java path is set correctly on your Windows 10 system, follow these steps:

  • Open a new Command Prompt window.
  • Type «java -version» and press Enter.
  • If the Java path is set correctly, you will see the version information displayed.

Congratulations! You have successfully set the Java path in Windows 10.

Setting the Java Home Variable

In addition to setting the Java path, it is also beneficial to set the Java Home variable. The Java Home variable points to the top-level directory of the JDK installation, and it is used by various Java tools and applications. By setting the Java Home variable, you can ensure that Java-related programs always reference the correct JDK installation.

Setting the Java Home Variable

To set the Java Home variable in Windows 10, follow these steps:

  • Open the Environment Variables settings as described in Step 2 of the previous section.
  • In the Environment Variables window, under the «System variables» section, click on the «New» button.
  • In the «Variable name» field, enter «JAVA_HOME«.
  • In the «Variable value» field, enter the path to the JDK installation directory. For example:
    • C:\Program Files\Java\jdk1.8.0_x (for Java 8)
    • C:\Program Files\Java\jdk-11 (for Java 11)
  • Click «OK» to save the changes.

By setting the Java Home variable, you have ensured that Java programs will always refer to the correct JDK installation directory.

Verifying the Java Home Variable

To verify if the Java Home variable is set correctly, follow these steps:

  • Open a Command Prompt window.
  • Type «echo %JAVA_HOME%» and press Enter.
  • If the Java Home variable is set correctly, you will see the JDK installation directory path displayed.

You have successfully set the Java Home variable in Windows 10.

In conclusion, setting the Java path and Java Home variable in Windows 10 is crucial for running Java applications, compiling code, and using Java tools. By following the steps outlined in this guide, you can ensure that your Windows 10 system is properly configured to utilize Java for your programming needs.

How To Set Java Path In Windows 10

Setting Java Path in Windows 10

Setting the Java path in Windows 10 is essential for running Java applications and programs smoothly. Follow these steps to set the Java path:

  • First, open the Windows Control Panel and search for «System».
  • In the System window, click on «Advanced system settings» on the left-hand side.
  • Click on the «Environment Variables» button at the bottom.
  • In the Environment Variables window, under «System Variables», click on «Path» and then click on «Edit».
  • Add the location of the Java installation directory by clicking on «New» and entering the path:
Variable name: PATH Variable value: C:\Program Files\Java\jdk1.8.0_221\bin

Note: Make sure to replace «C:\Program Files\Java\jdk1.8.0_221\bin» with the actual path of your Java installation directory.

Once you have added the Java path, click on «OK» to save the changes. Now you can run Java programs and applications without any issues.

Key Takeaways — How to Set Java Path in Windows 10

  • Setting the Java path in Windows 10 is essential for running Java applications.
  • To set the Java path in Windows 10, you need to locate the Java installation directory.
  • Add the Java installation directory to the PATH environment variable in Windows 10.
  • You can set the Java path in Windows 10 using the Control Panel or Command Prompt.
  • It is important to verify the Java path after setting it to ensure it is configured correctly.

Frequently Asked Questions

In this section, we will address some commonly asked questions related to setting the Java path in Windows 10.

1. How do I check if Java is already installed on my Windows 10?

If you are unsure whether Java is already installed on your Windows 10 system, you can check it by following these steps:

1. Open the Command Prompt by pressing Windows Key + R, then typing «cmd» and pressing Enter.

2. In the Command Prompt, type «java -version» (without the quotes) and press Enter.

If Java is installed, it will display the installed version of Java. If it is not installed, you will see an error message.

2. How do I set the Java path in Windows 10?

To set the Java path in Windows 10, you can follow these steps:

1. Open the Control Panel by searching for it in the Windows search bar.

2. In the Control Panel, click on «System and Security» and then click on «System».

3. On the left side of the System window, click on «Advanced system settings».

4. In the System Properties window, click on the «Environment Variables» button.

5. In the Environment Variables window, under the «System variables» section, click on the «New» button.

6. In the «New System Variable» window, enter «JAVA_HOME» in the «Variable name» field and the path to your Java installation directory in the «Variable value» field.

7. Click «OK» to save the variable.

8. In the Environment Variables window, scroll down to the «Path» variable under the «System variables» section and click on the «Edit» button.

9. In the Edit Environment Variable window, click on the «New» button and enter «%JAVA_HOME%\bin» in the field.

10. Click «OK» to save the variable.

11. Click «OK» in the Environment Variables window to apply the changes.

12. Close the Control Panel.

3. Do I need to restart my computer after setting the Java path?

Yes, it is recommended to restart your computer after setting the Java path in Windows 10. This allows the changes to take effect system-wide.

4. How do I test if the Java path is set correctly?

To test if the Java path is set correctly, you can follow these steps:

1. Open the Command Prompt by pressing Windows Key + R, then typing «cmd» and pressing Enter.

2. In the Command Prompt, type «java» (without the quotes) and press Enter.

If the Java path is set correctly, it will display the Java version and other information about the Java installation. If you see an error message, it means the Java path is not set correctly.

5. How do I update the Java path in Windows 10?

To update the Java path in Windows 10, you can follow these steps:

1. Open the Control Panel by searching for it in the Windows search bar.

2. In the Control Panel, click on «System and Security» and then click on «System».

3. On the left side of the System window, click on

Setting the Java path in Windows 10 is a simple process that ensures your computer recognizes and can execute Java programs. By following the steps outlined in this article, you can easily set the Java path and start developing Java applications.

Remember to download and install the latest version of Java from the official website. Then, modify the system environment variables by adding the Java path. This will allow you to run Java programs from anywhere on your computer.

Details
Written by  
Last Updated on 27 April 2019   |   Print  Email

In this article, you will understand the details about JAVA_HOME environment variable and how to set it on Windows 10. 

What is JAVA_HOME?

By convention, JAVA_HOME is the name of an environment variable on the operating system that points to the installation directory of JDK (Java Development Kit) or JRE (Java Runtime Environment) – thus the name Java Home. For example:

JAVA_HOME = c:\Program Files\Java\jdk1.8.0_201

Why is JAVA_HOME needed?

To develop Java applications, you need to update the PATH environment variable of the operating system so development tools like Eclipse, NetBeans, Tomcat… can be executed because these programs need JDK/JRE to function. So the PATH environment variable should include JAVA_HOME:

PATH = Other Paths + JAVA_HOME

Other paths are set by various programs installed in the operating system. If the PATH environment variable doesn’t contain a path to JRE/JDK, a Java-based program might not be able to run. For example, typing java in the command prompt showing this error:

'java' is not recognized as an internal or external command, operable program or batch file.

error java command

Or Eclipse will fail to launch:

How to set JAVA_HOME on Windows 10

Here are the visual steps to properly set value for the JAVA_HOME and update the PATH environment variables in order to setup Java development environment on your computer:

1. Firstly, you need to identify the Java home directory, which is typically under C:\Program Files\Java directory. Open My Computer and navigate to this directory, you will see:

Java home directory

Here, the home of JDK is under C:\Program Files\Java\jdk1.80_201. The version number may vary, depending on the JDK you installed.

2. Open the System Environment Variables dialog by typing environment in the search area on Start menu. Click the suggested item Edit the system environment variables:

The System Properties dialog appears, click the button Environment Variables.

System properties dialog

Then you will see this dialog:

Environment Variables dialog

3.Create the JAVA_HOME environment variable by clicking the New button at the bottom. In the New System Variable form, enter the name and value as follows:

New JAVA HOME system variable

Click OK, and you will see the JAVA_HOME variable is added to the list.

4.Update the PATH system variable. In the Environment Variables dialog, select the Path variable and click Edit:

Edit Path variable

Then in the Edit environment variable dialog, double click on the empty row just below the last text line, and enter %JAVA_HOME%\bin as follows:

Edit Path variable for Java home

The percent signs tell Windows that it refers to a variable – JAVA_HOME, and the \bin specifies the location of java.exe and javac.exe programs which are used to run and compile Java programs, as well as other tools in the JDK.

Click OK button to close all the dialogs, and you’re all set. Now you can open Eclipse or NetBeans to verify. Or open a command prompt and type in javac –version, you should see:

verify java home

NOTES:

You can add the path to the bin directory of Java home directly into the PATH variable. But it’s strongly recommend to follow the above steps to setup a JAVA_HOME variable because many Java programs depend on it.

When you installed a JDK, you might not need to update the system variable because the installer already did it for you.

Learn more:

  • How to set environment variables for Java using command line
  • How to write, compile and run a hello world Java program for beginners
  • What are JVM, JRE and JDK
  • How to check Java version

About the Author:

Nam Ha Minh is certified Java programmer (SCJP and SCWCD). He began programming with Java back in the days of Java 1.4 and has been passionate about it ever since. You can connect with him on Facebook and watch his Java videos on YouTube.

Add comment

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Microsoft windows search process
  • Не запускается windows 10 компьютер запущен некорректно
  • Windows vista что это такое
  • Tag scanner windows 10
  • Thaiphoon burner windows 11 ошибка