How to set JAVA_HOME in your in your environment
How to set JAVA_HOME in your in your environment
When installing some applications that would require to set JAVA_HOME path for your environment you would need in most cases to manually set the JAVA_HOME path as it would not be there automatically.
Normally the error you get for this is:
1 |
java_home not found in your environment |
Adding JAVA_HOME in your windows environment
To fix this error you just need to be sure you know where your JRE or JDK (depends on which one you need, in my case I needed the JDK path) folder path. This should be on windows inside the location
1 |
c:\Program Files\java\jdk |
if you are using x64 then check
1 |
c:\Program Files(x86)\java\jdk |
Then once you have the JRE or JDK path, follow:
- Right-click the My Computer icon on your desktop and select Properties.
- Click the Advanced tab.
- Click the Environment Variables button.
- Under System Variables, click New.
- Enter the variable name as
JAVA_HOME
. - Enter the variable value as the installation path for the Java Development Kit, for eg.
1 |
c:\Program Files(x86)\java\jdk |
Click ok and apply changes and also close any command prompt you still have opened.
Another method of doing this is using CMD directly, type the following command:
1 |
set JAVA_HOME=c:\Program Files(x86)\java\jdk |
This should create the JAVA_HOME variable with the given value.
In some case when you need this variable, you probably also need to make some more changes to your system path. In my case I had to install Maven so I needed to add the bin folder to the system PATH so that you can use the binary in any folders or in your JAVA applications.
To do this, I use the command line method, see bellow:
1 |
set PATH=c:\Users\MyUser\Desktop\Maven\bin;%PATH% |
%PATH%
is the current system PATH value, so after we declare our own, we add after the semicolons the existing current PATH value.
And that would be all for this tutorial, will see you again in our next one.