This short tutorial describes how to install Java on a W7 system and how to set-up the JAVA_HOME environment variable. It is useful only if you plan to make extensive use of Java, like playing with several version of the Java Virtual Machine (JVM). For basic usage, just click on the Java Download Page. Setting-up a JAVA_HOME environment variable is a common practice. That helps scripts to know what is your favorite Java JRE, in case you are dealing with several versions.
This paper is applicable for Windows 7. Please take care of the date of publication, as newer versions may have been delivered since.
[UPDATE: Java version numbers updated (not the screen-shots, sorry) and x64 version added for running Android Studio]
GET THE INSTALLERS
If you click on the Java Download Page, you will be proposed the best version for your system. In my case, the “ChromeInstall” will be selected. I did not see any difference between this version and the standard JRE install. If anybody knows, I’m interested.
You can download more versions on the Java SE downloads page. I suggest to choose:
- JRE 7 update 21 – the last version (always choose the up-to-date version)
- JRE 6 update 45 – to run older libraries not compatible with JRE 6
- JDK 7 update 21 – for compiling your code on Eclipse
- JDK 7 update 21 x64 – for running Android Studio and compile your code on it (this installer will also provide JRE 7 update 21) (neither JDK and JRE will be automatically updated)
CLEAN AND INSTALL
To be sure that everything is under control, I have removed any older versions of Java and any programs related to Java. All installers can now be launched. Everything is installed in the folder “C:\Program Files (x86)\Java” and ”C:\Program Files\Java” for the x64 version.
CREATE THE JAVA_HOME ENVIRONMENT VARIABLE
The following entries have to be added to the user environment variables:
- JAVA_HOME : C:\Program Files (x86)\Java\jre7
- PATH : %JAVA_HOME%\bin (or append it to the existing values)
I have underlined the user environment variables, because I have lost a couple of hours with this operation described in the Amazon Web Service documentation (which is excellent beside that).
If you do not know how to manage environment variables in W7, just Google it. You will find plenty of pages describing it, like this one.
Two more comments:
- Sometimes you read that this operation does not work if the absolute path contains spaces. This is not true, it’s working for me as described above.
- Do not mix system environment variables and user environment variables. That will not work (mind that there are two Path variables).
CHECK THAT EVERYTHING IS WORKING FINE
In Google Chrome, through the chrome:plugins page:
Using the Java download test page:
… or the Java check version page:
The version displayed here should always be the last Java version.
Thank to the Path append, you can also easily check the Java version in the console. This is done with the following command: