How can I change the Java Runtime Version on Windows.
I installed Java 7 for some tests, and now I need the old java6 as system default, but I don't want to uninstall the Java 7 (I need it for later tests). Can I change the system-used JRE in the control panel/Java/JRE tab? I can change/edit/add/delete the user-used version, but not the system-used.
If you are using windows 10 or windows server 2012, the steps to change the java runtime version is this:
All you need to do is set the PATH environment variable in Windows to point to where your java6 bin directory is instead of the java7 directory.
Right click My Computer > Advanced System Settings > Advanced > Environmental Variables
If there is a JAVA_HOME environment variable set this to point to the correct directory as well.
Go to control panel --> Java You can select the active version here
Since Java 1.6, a java.exe is installed into %windir%\system32 that supports a "-version" command line option. You can use this to select a specific version to run, e.g.:
java -version:1.7 -jar [path to jar file]
will run a jar application in java 1.7, if it is installed.
See Oracle's documentation here: http://docs.oracle.com/javase/6/docs/technotes/tools/windows/java.html
Once I updated my Java version to 8 as suggested by browser. However I had selected to uninstall previous Java 6 version I have been used for coding my projects. When I enter the command in "java -version" in cmd it showed 1.8 and I could not start eclipse IDE run on Java 1.6.
When I installed Java 8 update for the browser it had changed the "PATH" System variable appending "C:\ProgramData\Oracle\Java\javapath" to the beginning. Newly added path pointed to Java vesion 8. So I removed that path from "PATH" System variable and everything worked fine. :)
Update your environment variables
Ensure the reference to java/bin is up to date in 'Path'; This may be automatic if you have JAVA_HOME or equivalent set. If JAVA_HOME is set, simply update it to refer to the older JRE installation.
I use to work on UNIX-like machines, but recently I have had to do some work with Java on a Windows 7 machine. I have had that problem and this is the I've solved it. It has worked right for me so I hope it can be used for whoever who may have this problem in the future.
These steps are exposed considering a default Java installation on drive C. You should change what it is necessary in case your installation is not a default one.
Suppose we have installed Java 8 but for whatever reason we want to keep with Java 7.
1- Start a cmd as administrator
2- Go to C:\ProgramData\Oracle\Java
3- Rename the current directory javapath to javapath_<version_it_refers_to>. E.g.: rename javapath javapath_1.8
4- Create a javapath_<version_you_want_by_default> directory. E.g.: mkdir javapath_1.7
5- cd into it and create the following links:
cd javapath_1.7
mklink java.exe "C:\Program Files\Java\jre7\bin\java.exe"
mklink javaw.exe "C:\Program Files\Java\jre7\bin\javaw.exe"
mklink javaws.exe "C:\Program Files\Java\jre7\bin\javaws.exe"
6- cd out and create a directory link javapath pointing to the desired javapath. E.g.: mklink /D javapath javapath_1.7
7- Open the register and change the key HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\CurrentVersion to have the value 1.7
At this point if you execute java -version
you should see that you are using java version 1.7:
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
8- Finally it is a good idea to create the environment variable JAVA_HOME. To do that I create a directory link named CurrentVersion in C:\Program Files\Java pointing to the Java version I'm interested in. E.g.:
cd C:\Program Files\Java\
mklink /D CurrentVersion .\jdk1.7.0_71
9- And once this is done:
Source: Stackoverflow.com