Echo java home windows

Как прописать JAVA_HOME?

Картинка для привлечения внимание. Ноги, кафель, ну вы поняли.

Windows:

Приступим к настройке.

  1. Давим по значку рабочего стола правой кнопки мыши -> открывается окно «Система».
  2. На левой панели давим по пункту «Дополнительные параметры системы» -> открывается окно «Свойства системы»
  3. На вкладке «Дополнительно» нажимает на кнопку «Переменные среды. » -> открывается окно «Переменные среды»

Перед вами 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».

Set JAVA_HOME on Windows 7, 8, 10, Mac OS X, Linux

Last modified: January 18, 2020

Читайте также:  Драйверы для logitech momo racing windows 10 64 bit

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

  1. Open Search and type advanced system settings
  2. In the shown options, select the View advanced system settings link
  3. Under the Advanced tab, click Environment Variables
  4. In the System variables section, click New (or User variables for single user setting)
  5. Set JAVA_HOME as the Variable name and the path to the JDK installation as the Variable value and click OK
  6. Click OK and click Apply to apply the changes

2.2. Windows 7

  1. On the Desktop, right-click My Computer and select Properties
  2. Under the Advanced tab, click Environment Variables
  3. In the System variables section, click New (or User variables for single user setting)
  4. Set JAVA_HOME as the Variable name and the path to the JDK installation as the Variable value and click OK
  5. 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).

Читайте также:  Windows system serial number

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.

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

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.

How to set JAVA_HOME on Windows 10?

This tutorial shows you how to set a JAVA_HOME system variable on Windows 10.

1. Advanced System Settings

Type advanced system settings in the search box (beside the Windows start button), clicks View advanced system settings .

2. Environment Variables

Select Advance tab, clicks Environment Variables

Читайте также:  Mac os disable automatic updates

3. Add JAVA_HOME

In System variables, clicks New. button to add a new JAVA_HOME variable and point it to the JDK installed folder.

  1. Correct – C:\Program Files\Java\jdk1.8.0_60
  2. Wrong – C:\Program Files\Java\jdk1.8.0_60\bin

4. Update PATH

In System variables, find PATH , clicks edit. button :

4.1 In old version of Windows, it will prompt you below dialog box to edit the values directly, append this %JAVA_HOME%\bin; to the end of the line.

4.2 In latest Windows 10, it will prompt you below dialog box, clicks on New button, and add this %JAVA_HOME%\bin

echo %JAVA_HOME% returns %JAVA_HOME%

it returns %JAVA_HOME% on windows 10 what did I do wrong?

8 Answers 8

If you are sure that you have set them properly, you can print your environment variables like JAVA_HOME using any of the below methods in Windows 10.

Windows Command prompt ( cmd.exe )

Git Bash within windows, you need to use the bash format

From the conversation, it looks like you are using Windows 10 powershell.
To print the environment variable in windows powershell, use one of the following commands as below

You can refer the Powershell documentation here.

There is high possibility that you used the windows 10 powershell terminal unknowingly instead of the standard windows command prompt.

In a standard Windows command prompt you would type,

But in powershell you would see JAVA_HOME written out.

Powershell does things differently. In this case to output environment variables you need to use

The syntax depends on the shell/terminal you are using. Try

this is the syntax for bash, for instance if you are using Git Bash to run your commands.

If you just added the System Variable you need to reboot for System to read it

if you are using an classic cmd command «echo %JAVA_HOME%» in windowsJAVA is fine

Your command is correct for a windows 10 machine. And the result tells us, that this variable is not set. You can look for the settings for the environment variables in your start menu. You’ll see settings for other variables like Path, TEMP and so on. There you can add JAVA_HOME (here without %). The path would be like this (from my pc): C:\Program Files\Java\jdk1.8.0_161

It prints «JAVA_HOME» because you didn’t set JAVA_HOME variable or you have typo in variable name. Just go to your environment variables settings and check if it’s correct. If you don’t have JAVA_HOME there just look at this question: How to set JAVA_HOME

I know this answer is well overdue, but after hours of searching, it solved the problem for me.

Reinstall everything (git, jdk/jre, potentially maven), but when you do, leave EVERYTHING as its default value. Do not change any of the settings, DO NOT CHOOSE A SPECIFIC SAVE LOCATION that is convenient for you, etc. Leave everything as their default values.

Turns out, git is particularly rigid when it comes to flexibility, and it doesn’t play well if you change the install location. When I was installing git, I changed the save location. I had been installing and practicing a bunch of new tools, and I wanted to have them all in one isolated spot. Just goes to show that the default way is usually the best way.

Оцените статью