- Как прописать JAVA_HOME?
- Windows:
- Ubuntu:
- JRE_HOME
- Как установить JAVA_HOME в Windows 10
- Настройка JAVA_HOME в Windows 10
- Установите переменную среды JAVA_HOME и обновите системный путь
- Проверьте настройки конфигурации JAVA_HOME, используя CMD
- Set JAVA_HOME on Windows 7, 8, 10, Mac OS X, Linux
- Get started with Spring 5 and Spring Boot 2, through the Learn Spring course:
- 1. Overview
- 2. Windows
- 2.1. Windows 10 and 8
- 2.2. Windows 7
- 3. Mac OS X
- 3.1. Single User – Mac OS X 10.5 or Newer
- 3.2. Single User – Mac OS X Older Versions
- 3.3. Global Setting
- 4. Linux
- 4.1 Single User
- 4.2 Global Setting
- 5. Conclusion
- How to Find JAVA_HOME
- Get started with Spring 5 and Spring Boot 2, through the Learn Spring course:
- 1. Introduction
- 2. Windows-Specific Ways to Find JAVA_HOME
- 3. macOS and Linux-Specific Ways to Find JAVA_HOME
- 4. Using Java to Find JAVA_HOME
- 5. Conclusion
- 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
Как прописать JAVA_HOME?
Картинка для привлечения внимание. Ноги, кафель, ну вы поняли.
Windows:
Приступим к настройке.
- Давим по значку рабочего стола правой кнопки мыши -> открывается окно «Система».
- На левой панели давим по пункту «Дополнительные параметры системы» -> открывается окно «Свойства системы»
- На вкладке «Дополнительно» нажимает на кнопку «Переменные среды. » -> открывается окно «Переменные среды»
Перед вами 2 списка, в верхнем списке указаны все переменные доступные только вашему пользователю, в нижнем — всей системе. В некоторых случаях может потребоваться установить разные переменные JAVA_HOME для нескольких юзеров одной системы, в этом случае для каждого юзера придется прописать свою переменную в списке «Переменные среды пользователя». Мы пойдем обычным путем и установим одинаковую переменную для всех.
- Необходимо убедиться что переменной JAVA_HOME нет в списке, если есть, давим кнопку изменить и переходим к 6 пункту.
- Давим кнопку «Создать. «.
- Указываем имя переменной «JAVA_HOME», в значении переменной указываем полный путь до папки с JDK, например «C:\java\jdk1.7.0_79\».
Окно «Свойств системы» в Windows
Не будет лишним так-же указать переменную «JRE_HOME», она пригодится, например, для разработки портлетов для портала Liferay, для этого по аналогии повторите пункт 6. Как правило, JRE находится в папке с JDK, примерный путь «C:\java\jdk1.7.0_79\jre\».
После установки дистрибьютива JDK виртуальная машина «java.exe» будет доступна в консоли повсеместно. Для выполнения некоторых задач, необходимо так-же предоставить доступ к компилятору «javac.exe», для этого отредактируйте переменную Path. Добавьте в значение переменной «;» и путь до папки с компилятором, например «C:\Java\jdk1.7.0_79\bin\».
Ubuntu:
Для начала необходимо понять куда была установлена Java, выполните команды:
Результатом выполнения команды будет список установленных виртуальных машин Java:
Из этого списка нам потребуется столбик Path. Полный путь до виртуальных машин должен быть до «jre/bin/java», например в нашем случае 0-ой пункт будет иметь полный путь до машины «/usr/lib/jvm/java-8-oracle».
Для установки переменной JAVA_HOME, необходимо прописать ее в /etc/environment, используя путь до машины Java.
Изменения вступят в силу автоматически после перезагрузки, либо мы можем перегрузить переменные окружения командой:
Осталось выполнить проверку:
Если в результате команда напечатает путь до машины JAVA, значит настройка завершена успешно.
JRE_HOME
Не будет лишним так-же указать переменную «JRE_HOME», она пригодится, например, для разработки портлетов для портала Liferay. Как правило, JRE находится в папке с JDK, т.е. значение JRE_HOME = путь до виртуальной машины + «/jre».
Как установить JAVA_HOME в Windows 10
В терминологии Unix переменная окружения – это строка, содержащая такую информацию, как имя диска, имя пути, имя файла и т. Д. JAVA_HOME – это переменная среды, которая обращается к каталогу, где находится среда выполнения Java или Java Development Kit. установлен в системе. Точнее сказать, если вы установили Java по пути C: \ Program Files \ Java \ jdk1.8.0_121 на своем компьютере, то ваш Java_Home будет C: \ Program Files \ Java \ jdk1.8.0_121 . По сути, JAVA_Home – это просто пример, используемый программами на основе Java, такими как Apache Tomcat и другими инструментами сервера приложений, для определения местоположения Java в системе.
Эти сторонние программы используют переменные окружения, которые указывают на каталог JDK или JRE. Проще говоря, это позволяет программам легко находить исполняемый файл каталога, такой как javac, на компьютере. Если вы не используете эти сторонние программы, пользователям может быть необязательно устанавливать JAVA_Home в вашей системе. В этой статье мы подробно объясним, как установить JAVA_HOME в качестве переменной среды в Windows 10.
Настройка JAVA_HOME в Windows 10
Установите переменную среды JAVA_HOME и обновите системный путь
Загрузите и установите Java с официального сайта – java.com .
После установки перейдите в меню Пуск и введите Дополнительные параметры системы.
Нажмите Просмотреть дополнительные настройки системы в списке, чтобы открыть Свойства системы.
Перейдите на вкладку Дополнительно и нажмите кнопку Переменная среды .
В окне «Переменная среды» нажмите кнопку Создать под системной переменной.
В системной переменной Изменить укажите имя переменной в виде JAVA_HOME и значение переменной в качестве пути к каталогу JDK.
Нажмите ОК .
Теперь вернитесь в окно переменной среды и выберите путь в системной переменной.
Нажмите кнопку Изменить , чтобы открыть окно Изменить переменную среды.
Нажмите кнопку «Создать» и введите % JAVA_HOME% \ bin .
Нажмите ОК , чтобы применить изменения.
Проверьте настройки конфигурации JAVA_HOME, используя CMD
Чтобы проверить свою конфигурацию, откройте Командную строку .
Введите echo% JAVA_HOME% и нажмите Enter. Это должно напечатать каталог JDK, на который указывает JAVA_HOME. Вместо этого, если вы видите пробел, это означает, что вы не смогли настроить переменную среды.
Далее введите javac -version , который должен печатать версию компилятора Java.
Если нет, то будет напечатано сообщение о том, что javac не распознается как внутренняя или внешняя команда. Это означает, что переменная пути установлена неправильно.
Set JAVA_HOME on Windows 7, 8, 10, Mac OS X, Linux
Last modified: January 18, 2020
Get started with Spring 5 and Spring Boot 2, through the Learn Spring course:
If you have a few years of experience in the Java ecosystem, and you’re interested in sharing that experience with the community (and getting paid for your work of course), have a look at the «Write for Us» page. Cheers, Eugen
1. Overview
In this quick article, we’ll take a look at how to set the JAVA_HOME variable on Windows, Mac OS X, and Linux.
2. Windows
2.1. Windows 10 and 8
- Open Search and type advanced system settings
- In the shown options, select the View advanced system settings link
- Under the Advanced tab, click Environment Variables
- In the System variables section, click New (or User variables for single user setting)
- Set JAVA_HOME as the Variable name and the path to the JDK installation as the Variable value and click OK
- Click OK and click Apply to apply the changes
2.2. Windows 7
- On the Desktop, right-click My Computer and select Properties
- Under the Advanced tab, click Environment Variables
- In the System variables section, click New (or User variables for single user setting)
- Set JAVA_HOME as the Variable name and the path to the JDK installation as the Variable value and click OK
- Click OK and click Apply to apply the changes
Open Command Prompt and check the value of the JAVA_HOME variable:
The result should be the path to the JDK installation:
3. Mac OS X
3.1. Single User – Mac OS X 10.5 or Newer
From OS X 10.5, Apple introduced a command line tool (/usr/libexec/java_home) which dynamically finds the top Java version specified in Java Preferences for the current user.
/.bash_profile in any text editor and add:
Save and close the file.
Open a Terminal and run the source command to apply the changes:
Now we can check the value of the JAVA_HOME variable:
The result should be the path to the JDK installation:
3.2. Single User – Mac OS X Older Versions
For older versions of OS X, we have to set the exact path to the JDK installation:
/.bash_profile in any editor and add:
Save and close the file.
Open a Terminal and run the source command to apply the changes:
Now we can check the value of the JAVA_HOME variable:
The result should be the path to the JDK installation:
3.3. Global Setting
To set JAVA_HOME globally for all users, the steps are the same as for single user, but the file /etc/profile is used.
4. Linux
We’re going to manipulate the PATH here, of course – so, if you haven’t done that before, here are the detailed instructions on how to do it.
4.1 Single User
To set JAVA_HOME in Linux for a single user, we can use /etc/profile or /etc/environment (preferred for system-wide setting) or
/.bashrc (user-specific setting).
/.bashrc in any text editor and add:
Save and close the file.
Run the source command to load the variable:
Now we can check the value of the JAVA_HOME variable:
The result should be the path to the JDK installation:
4.2 Global Setting
To set JAVA_HOME in Linux for all users, we can use /etc/profile or /etc/environment (preferred).
Open /etc/environment in any text editor and add:
Please note that /etc/environment is not a script, but a list of assignment expressions (that is why export is not used). This file is read at the time of login.
To set JAVA_HOME using /etc/profile, open the file and add:
Run the source command to load the variable:
Now we can check the value of the JAVA_HOME variable:
The result should be the path to the JDK installation:
5. Conclusion
In this article, we have covered ways to set the JAVA_HOME environment variable on Windows, Mac OS X, and Linux.
How to Find JAVA_HOME
Last modified: March 7, 2020
Get started with Spring 5 and Spring Boot 2, through the Learn Spring course:
If you have a few years of experience in the Java ecosystem, and you’re interested in sharing that experience with the community (and getting paid for your work of course), have a look at the «Write for Us» page. Cheers, Eugen
1. Introduction
In this quick post, we’ll learn how to find JAVA_HOME on Windows, Mac, and Linux.
As we all know, JAVA_HOME is an environment variable that we commonly use to locate java executables like java and javac.
2. Windows-Specific Ways to Find JAVA_HOME
If we’re using Windows as the operating system, first we need to open up our command line (cmd) and type:
If JAVA_HOME is defined in our environment, then the above command will print it out.
Or, we could try:
Which will show the location of the java executable.
3. macOS and Linux-Specific Ways to Find JAVA_HOME
If we’re using either macOS or Linux, we can open up our terminal and type:
If JAVA_HOME is defined in our environment, then the above command will print it out.
Or, we could try:
Which probably just shows us /usr/bin/java.
But, really this isn’t very helpful since it’s a symbolic link. To unravel this, we’ll use dirname and readlink;
As a result, this command prints the currently used java folder.
4. Using Java to Find JAVA_HOME
And, if we’re able to run java ourselves, then we have a nearly platform-independent way, too:
Running this command outputs numerous properties, one of them being java.home.
To parse it, though, we’ll still need a platform-specific tool.
For Linux and macOS, let’s use grep:
And for Windows, let’s use findstr:
5. Conclusion
With this quick post, we’ve learned how to find JAVA_HOME on different operating systems.
If they didn’t work, though, maybe we didn’t set JAVA_HOME variable properly while installing Java.
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.