3

Before marking it duplicate FYI I have already read How can I change the Java Runtime Version on Windows (7)? and How to set path for Jre 6 when jre 7 installed?.

I have both Java7 and Java8 in my machine. I have

JAVA_HOME = C:\Program Files\Java\jdk1.7.0_60
PATH = ...;%JAVA_HOME%\bin;....

but I am getting

C:\>java -version
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

C:\>javac -version
javac 1.7.0_60

I want to set JRE to 1.7 too. How to do that?

Community
  • 1
  • 1
αƞjiβ
  • 3,056
  • 14
  • 58
  • 95
  • JRE 1.8 must be somewhere on the PATH before JDK 1.7. Type `echo %PATH%` and look through directories that are there – TMG Apr 20 '15 at 16:46

5 Answers5

3

You will probably have to edit your path environment variable.

If you want to check what's in your PATH environment variable in an organized fashion, run:

echo %path:;=&echo.%

Make sure the 1.8 is not on the path or if you want it there make sure it appears after 1.7.

To edit it, go to My Computer > Properties > System Properties > Advanced tab > Advanced section > Environment Variables.

Also check what is actually launched when you run java from the command line, run the following command:

where java

It will show you what windows runs when you request java.

nana
  • 4,426
  • 1
  • 34
  • 48
  • 1.8 is not in path at all. PATH has entry for 1.7 only. – αƞjiβ Apr 20 '15 at 16:40
  • Ahaa - I see there is an shortcut entry C:\ProgramData\Oracle\Java\javapath\java.exe pointing to 8. Does anyone know what this entry in path for? If not important I am planning to delete this entry or move to the end. – αƞjiβ Apr 20 '15 at 18:12
  • 2
    I'd rename it first to `java.exe.bak`, an see if it breaks anything. – nana Apr 20 '15 at 18:16
0

To solve the problem, remove or change the name of java.exe and javaw.exe into System32 folder:

Like this screenshot

Sphinx
  • 10,519
  • 2
  • 27
  • 45
0

Prepend the System Variable's Path with JRE bin's path.

TBag
  • 63
  • 6
0

where java did work for me. I found there is another version of java associated with the SPSS (1.8.0). Uninstall SPSS and the problem solved.

Tianxin Li
  • 101
  • 2
0

The solution that worked for me was: In "Path" variable replace "C:\ProgramData\Oracle\Java\javapath;" with %JAVA_HOME%\bin where JAVA_HOME variable was set to "C:\Program Files\Java\jdk1.7.0_60"

Terry
  • 53
  • 5