Cannot use Java 7 installation if Java 8 is installed

后端 未结 6 1180
野的像风
野的像风 2021-02-09 23:27

I normally still use Java 7 for all my coding projects (it\'s a company \"politics\" issue), but I installed Java 8 for one third-party project I am contributing to. Now, it see

相关标签:
6条回答
  • 2021-02-09 23:40

    Looks like you have to check where in your PATH is located your JAVA_HOME variable, the PATH is evaluated from left to right. A tip for you is to do all your Java system variables configuration at the beginning of your PATH.

    PATH = %M2_HOME%\bin;%JAVA_HOME%\bin;C:\ProgramData\Oracle\Java\javapath;...
    

    Probably that's why after doing this:

    - java -version
    

    you are getting this:

    - java version "1.8.0_05"
    

    because there are other areas in your PATH that are pointing to other java.exe, for example C:\Windows\System32 or C:\ProgramData\Oracle\Java\javapath etc.

    0 讨论(0)
  • 2021-02-09 23:46

    2 Steps

    1

    Change registry key **HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\CurrentVersion** to point to 1.7

    2

    Copy java.exe,javaw.exe and javaws.exe from your java 1.7 version to Windows\System32 folder (Since the corresponding files of java 1.8 are already there, you might have to overwrite with admin permissions)

    3

    (OOps actually not required 3rd step ) Open a new cmd window and check java -version

    0 讨论(0)
  • 2021-02-09 23:54

    I had to make 2 changes for it to work:

    1. Changed the Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVersion' to 1.7 from 1.8
    2. The Java 8 installation adds a new entry to the PATH environment variable 'C:\ProgramData\Oracle\Java\javapath'. I removed this entry from the PATH.
    0 讨论(0)
  • 2021-02-09 23:59

    Windows and Unix both find programs using their PATH environment variable. You have an java.exe in your Windows\System32 which is appearing before your "preferred" version of Java.

    Change the PATH to be the one you need, or specify the full path when you need a different version.

    0 讨论(0)
  • 2021-02-09 23:59

    When you install jdk8 it adds an entry like this

    C:\ProgramData\Oracle\Java\javapath

    to beginning of your PATH environment variable, removing this entry should resolve your problem.

    0 讨论(0)
  • 2021-02-10 00:03

    You can select the JRE version from the command line with the -version: option.

    > java -version:"1.7" MyClass
    

    should select the 1.7 JRE if installed properly.

    The list of the properly installed JRE is in the registry, see the key :

    HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment  (32bit)
    HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment  (64bit)
    

    You can set the "CurrentVersion" there if you want a different default version than the latest.

    See http://docs.oracle.com/javase/7/docs/technotes/tools/windows/java.html#options

    Don't modify your PATH to point to a particuliar JRE, let the special java.exe in Windows/system32 do the job.

    0 讨论(0)
提交回复
热议问题