- How To Set Java, JRE and JDK Home Path and Environment Variables On Windows?
- Locate JRE or JDK Path
- Set Java HOME_PATH Environment Variable
- Set JAVA Executable Path
- Check Java Is Working
- 3 thoughts on “How To Set Java, JRE and JDK Home Path and Environment Variables On Windows?”
- Переменная окружения JAVA_HOME – что это такое и она нужна
- Что такое JAVA_HOME
- Какие программы используют JAVA_HOME
- Ошибки, связанные с JAVA_HOME
- Как установить переменную окружения JAVA_HOME в Windows
- Резюме
- Confluence Support
- Knowledge base
- Products
- Jira Software
- Jira Service Management
- Jira Core
- Confluence
- Bitbucket
- Resources
- Documentation
- Community
- Suggestions and bugs
- Marketplace
- Billing and licensing
- Viewport
- Confluence
- Setting the JAVA_HOME Variable in Windows
- Installing Java for Confluence
- On this page
- Related content
- Still need help?
- Set the JAVA_HOME Variable
- Set the JAVA_HOME variable via the command line
- Setting up enviromental variables in Windows 10 to use java and javac
- 7 Answers 7
- Environment variables for java installation
- 14 Answers 14
- Java SE Development Kit 8u112 on a 64-bit Windows 7 or Windows 8
- Optional recommendations
How To Set Java, JRE and JDK Home Path and Environment Variables On Windows?
Java is a very popular programming language which provides a different component in order to run, develop Java applications. JRE or Java Runtime Environment is used to run Java application. JDK or Java Development Kit is used to develop Java applications. In this tutorial, we will learn how to set up Java, JRE, and JDK operating system path variables in order to work properly.
Locate JRE or JDK Path
Before starting the configuration we have to locate the JRE or JDK path. JRE or JDK generally installed on the Program Files or Program Files(x86) directory under the Java directory like below.
Locate JRE or JDK Path
and under the Java directory the JDK is residing.
Locate JRE or JDK Path
Set Java HOME_PATH Environment Variable
Now we have learned the path of the Java, JRE or JDK installation. We can set this path as Java HOME_PATH environment variable. We will open the computer properties with by running sysdm.cpl in the Run menu like below. We can also open it from the File Explorer -> Computer -> Right Click.
Open System Properties
In the system properties, we will navigate to the Advanced tab which provides the Environment Variables button like below.
Open Environment Variables
Below we can see the environment variables menu where we will create the JAVA_HOME system variable and set the path accordingly. We click to the New in order to create a new system variable.
Create New System Variable
Here we will set the Variable Name as JAVA_HOME and the Variable Value the path or Java, JRE or JDK which is C:\Program Files\Java\jdk-12 in this example. Then we will click OK.
Set JAVA Executable Path
If we want to run java.exe or similar executables provided by JRE or JDK we have to add the path of Java in the Path variable like below. We select the system variable named Path and click to the Edit .
Here we click to New which will add a new line to the existing values.
Here we will set the bin folder path which is C:\Program Files\Java\jdk-12\bin in this example.
Add Path System Variable
Then we will click OK and OK in the environment variables screen which will save and activated new path configuration.
Check Java Is Working
We can check the new path configuration simply opening a new command line interface MS-DOS. Then just type java -version which will execute java.exe with the -version option. We can see the current java binary version by running it.
3 thoughts on “How To Set Java, JRE and JDK Home Path and Environment Variables On Windows?”
What is the point in setting the JAVA_HOME to the path to the jdk install folder path if you then edit the Path variable and add the full path to the jdk bin folder? Shouldn’t you make use of the JAVA_HOME variable and add %JAVA_HOME%\bin to the Path instead.
@James Coffey, maybe the point of setting JAVA_HOME is just in preparation for GlassFish:
https://docs.oracle.com/cd/E19182-01/820-7851/inst_cli_jdk_javahome_t/index.html
Still, the author could make use of it in Path as you say, but maybe the author is just trying to keep it simple.
THANK YOU SO MUCH. YOU SAVED MY LIFE. I need to use java in jupyter
Переменная окружения JAVA_HOME – что это такое и она нужна
Во многих статьях в интернете, документации к инструментам для разработки на Java и в книгах зачастую упоминается JAVA_HOME. Что же такое JAVA_HOME?
Что такое JAVA_HOME
JAVA_HOME это переменная окружения, указывающая на директорию с установленным JDK (Java Development Kit, комплект разработчика Java). JAVA_HOME это соглашение, используемое во многих программах из экосистемы Java.
Какие программы используют JAVA_HOME
- Intellij IDEA, Eclipse, NetBeans
- Apache Maven, Apache Ant, Gradle
- Apache Tomcat
- Jenkins
Некоторые игры, написанные на Java (например, Minecraft), тоже могут требовать установленной переменной JAVA_HOME.
Ошибки, связанные с JAVA_HOME
Если переменная окружения JAVA_HOME не определена, некоторые программы могут выдавать следующие ошибки:
- Переменная среды java_home не определена
- Cannot determine a valid Java Home
- JAVA_HOME is set to an invalid directory
- JAVA_HOME is not defined correctly
- JAVA_HOME environment variable is not set
- JAVA_HOME command not found
- JAVA_HOME not found in your environment
- JAVA_HOME does not point to the JDK
При появлении таких ошибок просто установите переменную JAVA_HOME
Как установить переменную окружения JAVA_HOME в Windows
Сперва вам нужно установить JDK или JRE.
- Установите JDK, если вы занимаетесь разработкой программ на Java
- Установите JRE, если вам нужно только запустить прикладную программу на Java
После установки JDK либо JRE запишите путь установки, он понадобится.
Теперь щёлкните правой кнопкой на «Мой компьютер» → «Свойства» → «Дополнительные параметры системы» → «Переменные среды…». В разделе «Системные переменные» нажмите кнопку «Создать…» и укажите следующие данные:
Имя переменной | JAVA_HOME |
Значение переменной | Путь к директории JDK / JRE, например: C:\Java\jdk-11.0.6 |
Сохраните изменения, кликнув «OK». Теперь выберите в списке переменную окружения Path и нажмите «Изменить…». В конце списка добавьте строчку со значением «%JAVA_HOME%\bin«
Для проверки откройте консоль (Win+R, cmd) и укажите последовательно укажите две команды:
Если вы правильно установили JDK/JRE и правильно установили переменные окружения, вы увидите вывод наподобие этого:
Это будет служить результатом того, что переменная JAVA_HOME установлена правильно и Java работает из командной строки.
Резюме
В данной статье мы рассказали вам, что являет собой переменная окружения JAVA_HOME, где она используется и как её корректно указать.
Confluence Support
Knowledge base
Products
Jira Software
Project and issue tracking
Jira Service Management
Service management and customer support
Jira Core
Manage any business project
Confluence
Bitbucket
Git code management
Resources
Documentation
Usage and admin help
Community
Answers, support, and inspiration
Suggestions and bugs
Feature suggestions and bug reports
Marketplace
Billing and licensing
Frequently asked questions
Viewport
Confluence
Versions
Setting the JAVA_HOME Variable in Windows
Installing Java for Confluence
On this page
Related content
Still need help?
The Atlassian Community is here for you.
To install Confluence manually on Windows, you will need to set an environment variable to point Confluence to the your Java installation directory.
This information is only relevant if you’re installing Confluence manually on a Windows server. If you’re using the installer, you don’t need to do this.
In most cases you should set the JRE_HOME environment variable, but if it is not set, Confluence will use JAVA_HOME.
Related pages
Set the JAVA_HOME Variable
To set the JRE_HOME or JAVA_HOME variable:
Locate your Java installation directory
If you didn’t change the path during installation, it’ll be something like C:\Program Files\Java\jdk1.8.0_65
You can also type where java at the command prompt.
In the Variable Value field, enter your JDK or JRE installation path .
If the path contains spaces, use the shortened path name. For example, C:\Progra
Note for Windows users on 64-bit systems
1 = ‘Program Files’
Progra
2 = ‘Program Files(x86)’
You’ll need to close and re-open any command windows that were open before you made these changes, as there’s no way to reload environment variables from an active command prompt. If the changes don’t take effect after reopening the command window, restart Windows.
Set the JAVA_HOME variable via the command line
If you would prefer to set the JAVA_HOME (or JRE_HOME) variable via the command line:
- Open Command Prompt (make sure you Run as administrator so you’re able to add a system environment variable).
Set the value of the environment variable to your JDK (or JRE) installation path as follows:
If the path contains spaces, use the shortened path name.
Restart Command Prompt to reload the environment variables then use the following command to check the it’s been added correctly.
You should see the path to your JDK (or JRE) installation.
Setting up enviromental variables in Windows 10 to use java and javac
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.
7 Answers 7
Just set the path variable to JDK bin in environment variables.
But the best practice is to set JAVA_HOME and PATH as follow.
Here are the typical steps to set JAVA_HOME on Windows 10.
- Search for Advanced System Settings in your windows Search box. Click on Advanced System Settings.
- Click on Environment variables button: Environment Variables popup will open.
- Goto system variables session, and click on New button to create new variable (HOME_PATH), then New System Variables popup will open.
- 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.
- Now you are able to see your JAVA_HOME in system variables list. (If you are not able to, try doing it again.)
- 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.
- Click on New button and give %JAVA_HOME%\bin at highlighted field and click Ok button.
You can find complete tutorials on my blog :
Environment variables for java installation
How to set the environment variables for Java in Windows (the classpath)?
14 Answers 14
Java SE Development Kit 8u112 on a 64-bit Windows 7 or Windows 8
Set the following user environment variables (== environment variables of type user variables)
- JAVA_HOME : C:\Program Files\Java\jdk1.8.0_112
- JDK_HOME : %JAVA_HOME%
- JRE_HOME : %JAVA_HOME%\jre
- CLASSPATH : .;%JAVA_HOME%\lib;%JAVA_HOME%\jre\lib
- PATH : your-unique-entries;%JAVA_HOME%\bin (make sure that the longish your-unique-entries does not contain any other references to another Java installation folder.
Note for Windows users on 64-bit systems:
Notice that these environment variables are derived from the «root» environment variable JAVA_HOME . This makes it easy to update your environment variables when updating the JDK. Just point JAVA_HOME to the fresh installation.
Optional recommendations
- Add an user environment variable JAVA_TOOL_OPTIONS with value -Dfile.encoding=»UTF-8″ . This ensures that Java (and tools such as Maven) will run with a Charset.defaultCharset() of UTF-8 (instead of the default Windows-1252 ). This has saved a lot of headaches when wirking with my own code and that of others, which unfortunately often assume the (sane) default encoding UTF-8.
- When JDK is installed, it adds to the system environment variable Path an entry C:\ProgramData\Oracle\Java\javapath; . I anecdotally noticed that the links in that directory didn’t get updated during an JDK installation update. So it’s best to remove C:\ProgramData\Oracle\Java\javapath; from the Path system environment variable in order to have a consistent environment.
In Windows inorder to set
Step 1 : Right Click on MyComputer and click on properties .
Step 2 : Click on Advanced tab
Step 3: Click on Environment Variables
Step 4: Create a new class path for JAVA_HOME
Step 5: Enter the Variable name as JAVA_HOME and the value to your jdk bin path ie c:\Programfiles\Java\jdk-1.6\bin and
NOTE Make sure u start with .; in the Value so that it doesn’t corrupt the other environment variables which is already set.
Step 6 : Follow the Above step and edit the Path in System Variables add the following ;c:\Programfiles\Java\jdk-1.6\bin in the value column.
Step 7 :Your are done setting up your environment variables for your Java , In order to test it go to command prompt and type
who will get a list of help doc
In order make sure whether compiler is setup Type in cmd
who will get a list related to javac
Hope this Helps !
— To set java path —
There are two ways to set java path
A. Temporary
- Open cmd
- Write in cmd : javac
If java is not installed, then you will see message:
javac is not recognized as internal or external command, operable program or batch file.
- Write in cmd : set path=C:\Program Files\Java\jdk1.8.0_121\bin
- Write in cmd : javac
You can check that path is set if not error has been raised.
It is important to note that these changes are only temporary from programs launched from this cmd.
NOTE: You might have to run the command line as admin
B. Permanent
- Righ-click on «My computer» and click on properties
- Click on «Advanced system settings»
- Click on «Environment variables»
- Click on new tab of user variable
- Write path in variable name
- Copy the path of bin folder
- Paste the path of the bin folder in the variable value
- Click OK
The path is now set permanently.
TIP: The tool «Rapid Environment Editor» (freeware) is great for modifying the environment variables and useful in that case