Cannot use Java 7 installation if Java 8 is installed

I still use Java 7 for all my coding projects (this is a company policy issue), but I installed Java 8 for one third-party project, to which I contribute. Now it seems that I cannot install Java 8 on Windows 7 x64 and still use Java 7 by default:

C:\>"%JAVA_HOME%\bin\java.exe" -version
java version "1.7.0_55"
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)

C:\>java.exe -version
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)

As you can see, JAVA_HOME is completely ignored.

I also have Java in the path using "% JAVA_HOME% \ bin" that correctly enable Java 7 when I check the path in the DOS window, but it still doesn't matter.

I checked in the "Java Control Panel" (not sure if this affects the default version of Java for the command line). On the tab "Java", "View ...", you will see the "registered" version of Java. I can add all versions under the "User" tab, but in the "System" section there is only Java 8, and there is no way to change it.

Am I missing something, or is Oracle just unable to use Java 7 if I do not remove the installation of Java 8? I don’t want to indicate “source” and “target” everywhere, and I don’t even know if I can specify it wherever Java is used.

EDIT: , Java. Java7 ( 86, 64), Java8 ( 86, x64). , x64 JDK . , Java8 . JDK 7 x64 JDK 8 x64. , JDK7 x64, , "" "java.exe", "Windows" ( , ).

+6
6

Windows Unix , PATH. java.exe Windows\System32, "" Java.

PATH , , , .

+2

jdk8, ,

C:\ProgramData\Oracle\Java\javapath

PATH, .

+10

JRE -version:.

> java -version:"1.7" MyClass

1.7 JRE, .

JRE , . :

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

"CurrentVersion" , , .

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

PATH, JRE, java.exe Windows/system32 .

+3

2

1

**HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\CurrentVersion** 1.7

2

java.exe,javaw.exe and javaws.exe java 1.7 Windows\System32 ( java 1.8 , )

3

(OOps 3- ) cmd java -version

+1

, , PATH JAVA_HOME, PATH . - Java PATH.

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

, :

- java -version

:

- java version "1.8.0_05"

PATH , java.exe, C:\Windows\System32 C:\ProgramData\Oracle\Java\javapath ..

+1
source

I had to make 2 changes to work:

  • The registry key 'Software \ JavaSoft \ Java Runtime Environment' \ CurrentVersion 'has been changed to 1.7 out of 1.8
  • Installing Java 8 adds a new entry to the PATH environment variable 'C: \ ProgramData \ Oracle \ Java \ javapath'. I deleted this entry from PATH.
0
source

Source: https://habr.com/ru/post/1542088/


All Articles