How can I change the Java Runtime Version on Windows (7)?

后端 未结 8 728
后悔当初
后悔当初 2020-12-07 10:02

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 un

相关标签:
8条回答
  • 2020-12-07 10:15

    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.

    Change Java default VM on Windows 7

    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:

    • Right click My Computer and select Properties.
    • On the Advanced tab, select Environment Variables, and then edit/create JAVA_HOME to point to where the JDK software is located, in that case, C:\Program Files\Java\CurrentVersion
    0 讨论(0)
  • 2020-12-07 10:20

    Go to control panel --> Java You can select the active version here

    0 讨论(0)
  • 2020-12-07 10:27

    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.

    0 讨论(0)
  • 2020-12-07 10:31

    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. :)

    0 讨论(0)
  • 2020-12-07 10:36

    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.

    0 讨论(0)
  • 2020-12-07 10:37

    If you are using windows 10 or windows server 2012, the steps to change the java runtime version is this:

    1. Open regedit using 'Run'
    2. Navigate to HKEY_LOCAL_MACHINE -> SOFTWARE -> JavaSoft -> Java Runtime Environment
    3. Here you will see all the versions of java you installed on your PC. For me I have several versions of java 1.8 installed, so the folder displayed here are 1.8, 1.8.0_162 and 1.8.0_171
    4. Click the '1.8' folder, then double click the JavaHome and RuntimeLib keys, Change the version number inside to whichever Java version you want your PC to run on. For example, if the Value data of the key is 'C:\Program Files\Java\jre1.8.0_171', you can change this to 'C:\Program Files\Java\jre1.8.0_162'.
    5. You can then verify the version change by typing 'java -version' on the command line.
    0 讨论(0)
提交回复
热议问题