Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot use Java 7 installation if Java 8 is installed

Tags:

java

windows

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 seems I cannot have Java 8 installed in 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", which resolve correctly to Java 7 when I check the path in a DOS box, but it still makes no difference.

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

Am I missing something, or did Oracle just make it impossible to use Java 7, unless I de-install Java 8? I don't want to have to specify the "source" and "target" everywhere, and I don't even know if it is possible for me to specify it everywhere, where Java is used.

EDIT: What I did is I de-installed all Java. Then installed the latest Java7 (both 86 and x64), and then the latest Java8 (both 86 and x64). After I did that, I noticed that the x64 JDK was gone. It seems Java8 killed it. So I re-installed the JDK 7 x64, after the JDK 8 x64. Still, JDK7 x64 did not seem to "replace" the "java.exe" which is copied into the "Windows" directory itself (I assume THAT is the problem).

like image 203
Sebastien Diot Avatar asked May 26 '14 21:05

Sebastien Diot


People also ask

Can I have both Java 7 and 8 installed?

As Cootri has stated - you can install any number of Java versions on windows machines. JAVA_HOME and PATH will be needed. Save this answer.

Is Java 8 backwards compatible?

Incompatibilities between Java SE 8 and Java SE 7. Java SE 8 is strongly compatible with previous versions of the Java platform. Almost all existing programs should run on Java SE 8 without modification.

Can I have both Java 8 and 11 installed?

I know you can install both. Java 8 and Java 11 and keep them at the same time...

Can I still use Java 7?

Community support will end when Java 7 reaches End Of Life on 29 July 2022. Any applications running on Java 7 will continue to run, but Java 7 itself won't receive updates or security patches.


1 Answers

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.

like image 179
Jamali Avatar answered Sep 18 '22 21:09

Jamali