Add java to path windows 10

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.

I got a new laptop with Windows 10 and I want to set it up so I can use java and javac from the command line.

I have searched online but all the guides are for previous versions, and I don’t want to mess around with something I don’t understand.

General Grievance's user avatar

asked Aug 27, 2015 at 5:13

kilmarta's user avatar

0

Just set the path variable to JDK bin in environment variables.

Variable Name : PATH 
Variable Value : C:\Program Files\Java\jdk1.8.0_31\bin

But the best practice is to set JAVA_HOME and PATH as follow.

Variable Name : JAVA_HOME
Variable Value : C:\Program Files\Java\jdk1.8.0_31

Variable Name : PATH 
Variable Value : %JAVA_HOME%\bin

answered Aug 27, 2015 at 5:31

isurujay's user avatar

isurujayisurujay

1,38610 silver badges15 bronze badges

3

Here are the typical steps to set JAVA_HOME on Windows 10.

  1. Search for Advanced System Settings in your windows Search box. Click on Advanced System Settings.
  2. Click on Environment variables button: Environment Variables popup will open.
  3. Goto system variables session, and click on New button to create new variable (HOME_PATH), then New System Variables popup will open.
  4. Give Variable Name: JAVA_HOME, and Variable value : Your Java SDK home path. Ex: C:\Program Files\java\jdk1.8.0_151 Note: It should not include \bin. Then click on OK button.
  5. Now you are able to see your JAVA_HOME in system variables list. (If you are not able to, try doing it again.)
  6. Select Path (from system variables list) and click on Edit button, A new pop will opens (Edit Environment Variables). It was introduced in windows 10.
  7. Click on New button and give %JAVA_HOME%\bin at highlighted field and click Ok button.

You can find complete tutorials on my blog :

How to set JAVA_HOME in 64 bit Windows 10 OS

Monish Saravana 's user avatar

answered Dec 20, 2017 at 8:51

Chandra Shekhar Goka's user avatar

0

  • Right click Computer
  • Click the properties
  • On the left pane select Advanced System Settings
  • Select Environment Variables
  • Under the System Variables, Select PATH and click edit,
    and then click new and add path as C:\Program
    Files\Java\jdk1.8.0_131\bin
    (depending on your installation path)
    and finally click ok
  • Next restart your command prompt and open it and try javac

answered Jun 7, 2017 at 7:40

Navin prasad's user avatar

Navin prasadNavin prasad

5681 gold badge8 silver badges18 bronze badges

0

To find the env vars dialog in Windows 10:

Right Click Start
>>  Click Control Panel  (Or you may have System in the list)
>>  Click System
>>  Click Advanced system settings
>>  Go to the Advanced Tab
>>  Click the "Environment Variables..." button at the bottom of that dialog page.

answered Mar 24, 2016 at 10:31

theINtoy's user avatar

theINtoytheINtoy

3,3982 gold badges37 silver badges60 bronze badges

1

Its still the same concept, you’ll need to setup path variable so that windows is aware of the java executable and u can run it from command prompt conveniently

Details from the java’s own page: https://java.com/en/download/help/path.xml
That article applies to: •Platform(s): Solaris SPARC, Solaris x86, Red Hat Linux, SUSE Linux, Windows 8, Windows 7, Vista, Windows XP, Windows 10

answered Aug 27, 2015 at 5:21

whitecoffee's user avatar

2

if you have any version problems (javac -version=15.0.1, java -version=1.8.0)
windows search : edit environment variables for your account
then delete these in your windows Environment variable: system variable: Path
C:\Program Files (x86)\Common Files\Oracle\Java\javapath
C:\Program Files\Common Files\Oracle\Java\javapath

then if you’re using java 15
environment variable: system variable : Path
add path C:\Program Files\Java\jdk-15.0.1\bin
is enough

if you’re using java 8

  • create JAVA_HOME
  • environment variable: system variable : JAVA_HOME
    JAVA_HOME = C:\Program Files\Java\jdk1.8.0_271

  • environment variable: system variable : Path
    add path = %JAVA_HOME%\bin
  • answered Nov 27, 2020 at 8:27

    tharsikan's user avatar

    1

    Ответы

    Аватар пользователя Иван Полежаев

    Для добавления пути к 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 из любого места в файловой системе.

    Курсы по программированию на Хекслете

    Backend-разработка

    Разработка серверной части сайтов и веб-приложений

    Обложка категории Backend-разработка

    Frontend-разработка

    Разработка внешнего интерфейса сайтов и веб-приложений и верстка

    Обложка категории Frontend-разработка

    Создание сайтов

    Разработка сайтов и веб-приложений на JS, Python, Java, PHP и Ruby on Rails

    Обложка категории Создание сайтов

    Тестирование

    Ручное тестирование и автоматизированное тестирование на JS, Python, Java и PHP

    Обложка категории Тестирование

    Аналитика данных

    Сбор, анализ и интерпретация данных на Python

    Обложка категории Аналитика данных

    Интенсивные курсы

    Интенсивное обучение для продолжающих

    Обложка категории Интенсивные курсы

    DevOps

    Автоматизация настройки локального окружения и серверов, развертывания и деплоя

    Обложка категории DevOps

    Веб-разработка

    Разработка, верстка и деплой сайтов и веб-приложений, трудоустройство для разработчиков

    Обложка категории Веб-разработка

    Математика для программистов

    Обучение разделам математики, которые будут полезны при изучении программирования

    Обложка категории Математика для программистов

    JavaScript

    Разработка сайтов и веб-приложений и автоматизированное тестирование на JS

    Обложка категории JavaScript

    Python

    Веб-разработка, автоматическое тестирование и аналитика данных на Python

    Обложка категории Python

    Java

    Веб-разработка и автоматическое тестирование на Java

    Обложка категории Java

    PHP

    Веб-разработка и автоматическое тестирование на PHP

    Обложка категории PHP

    Ruby

    Разработка сайтов и веб-приложений на Ruby on Rails

    Обложка категории Ruby

    Go

    Курсы по веб-разработке на языке Go

    Обложка категории Go

    HTML

    Современная верстка с помощью HTML и CSS

    Обложка категории HTML

    SQL

    Проектирование базы данных, выполнение SQL-запросов и изучение реляционных СУБД

    Обложка категории SQL

    Git

    Система управления версиями Git, регулярные выражения и основы командой строки

    Обложка категории Git

    Похожие вопросы

    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:

    Eclipse launch error no Java home found

     

    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:

    start menu open system environment variable dialog

    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 started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.

    Add comment

    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 setting the path for both Windows and Linux:

    Setting Java Path in Windows

    1. Go to the Search box and type advanced system settings in it. Now click on the View advanced system settings.

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

    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.

    4. Now in the system variables go to the path and click the edit button.

    5. Click the New button.

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

    Setting 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.

    Last Updated :
    08 Sep, 2022

    Like Article

    Save Article

  • Adi 1988a b audio driver windows 10 64 bit
  • Add gradle to path windows
  • Adblock plus edge windows 10
  • Add windows terminal to context menu
  • Adb как пользоваться на windows 10