1

I found a few similar questions here on SO but
none of them seems to provide an actual answer.

I have these two versions.

 Directory of C:\Java\Bit64

01/19/2014  05:40 AM    <DIR>          .
01/19/2014  05:40 AM    <DIR>          ..
10/18/2013  07:53 AM    <DIR>          jdk1.6.0_45
01/19/2014  05:42 AM    <DIR>          jdk1.7.0_51
10/16/2013  03:15 PM    <DIR>          jre1.6.0_45
01/19/2014  05:40 AM    <DIR>          jre1.7.0_51
               0 File(s)              0 bytes
               6 Dir(s)  45,369,233,408 bytes free

C:\Java\Bit64>

I want my Java 6 version to be the default one.

Unfortunately in C:\Windows\System32 I have some other
java.exe which I am not sure when and how was installed by me.

C:\Windows\System32>dir jav*
 Volume in drive C is OS
 Volume Serial Number is xxxx-yyyy

 Directory of C:\Windows\System32

01/19/2014  05:40 AM           189,352 java.exe
01/19/2014  05:40 AM           189,352 javaw.exe
01/19/2014  05:40 AM           312,744 javaws.exe
               3 File(s)        731,896 bytes
               0 Dir(s)  45,369,040,896 bytes free

C:\Windows\System32>

Unfortunately I cannot even rename the java.exe in System32.

    C:\Windows\System32>move java.exe  java___exe
    Access is denied.
            0 file(s) moved.

I recall there were some options for this in the Java
Control panel but I am not sure which ones exactly.

So ...

(1) How do I make my Java 6 the default one in the right way?

I am not sure I want to put on my PATH %java_home%\bin before
C:\Windows\System32. But even if I do this, it still picks up Java 7.

(2) Why?!

(3) If I reinstall both versions will it help?

EDIT 1:

This is the most weird thing (I tried that based
on a few comments posted under this question).

    C:\>echo %java_home%
    C:\Java\Bit64\jdk1.6.0_45

    C:\>echo %path%
    %java_home%\bin;C:\Python27\Lib\site-packages\PyQt4;.....................

    C:\>java -version
    Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
    java version "1.7.0_51"
    Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
    Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

    C:\>

EDIT 2:

OK, I uninstalled both JDKs. Then I installed JDK 7 and
JDK 6 (without any public JREs). And I installed 6 after 7.

(4) Does anyone know what this key 'current version' means
and which program uses it? I was expecting it to be set to
1.6 as I installed JDK 6 second. Still, right now I don't
see any issues, JDK 6 is default, I guess due to %java_home%\bin
being the very first thing on the %path%.

registry

peter.petrov
  • 38,363
  • 16
  • 94
  • 159
  • "I am not sure I want to put on my PATH %java_home%/bin before C:\Windows\System32" What happened when you tried exactly that? – Kevin Workman Jan 28 '14 at 17:43
  • @KevinWorkman I didn't try it. I don't feel like this is the right way. Is it? – peter.petrov Jan 28 '14 at 17:43
  • 2
    Only one way to find out! Surely simply trying it would be faster than asking strangers on the internet, right? – Kevin Workman Jan 28 '14 at 17:45
  • You need to be a local administrator in order to be able to delete a file from `System32`. Your only solution is to put `%java_home%\bin` before `System32` into the path. –  Jan 28 '14 at 17:47
  • its not recommended to do anything in the System 32 directory ... Just JAVA_HOME and path as suggested by Kevin – Neeraj Krishna Jan 28 '14 at 17:48
  • 2
    @NeerajKrishna: actually it is not recommended for any 3rd party software to *install* anything into `system32`. That's the first thing I do after installing Java: delete those files from that directory. Btw: `java.exe` is not copied into `System32` if the option to install a "public JRE" is disabled during installation - not a bad choice anyway because that also installs the dreaded browser plugin. –  Jan 28 '14 at 17:50
  • This does not work too. See updated question. – peter.petrov Jan 28 '14 at 17:50
  • I tried the suggestion made here. It does not work too, I have no idea why Java 7 is still being picked up. See please the updated question. – peter.petrov Jan 28 '14 at 18:02
  • @a_horse_with_no_name I think I will try that. Clean install with the option 'install public JRE' unselected. – peter.petrov Jan 28 '14 at 19:56

2 Answers2

3

What a_horse_with_no_name suggested fixed my problem.

I uninstalled both JDKs (6 and 7), then I reinstalled both of them without
checking the 'install public JRE' option. This really fixed everything. Now the behavior is totally predictable (I can control it with setting my Windows PATH in the way I want).
Also, I don't have any java.exe in my System32 folder.

Posting this answer here just so that others could benefit from it.

peter.petrov
  • 38,363
  • 16
  • 94
  • 159
1

Looks like you might be on Windows 7 (I could be wrong). You can access the Java control panel by:

Start > Control Panel 
Click "Programs" 
Then "Java" should appear on the bottom (below Desktop Gadgets). 
Click on Java then select the "Java" tab in the "Java Control Panel". 
Click the "View..." button.
Then you can click Find or Add and then check "Enabled" for the one you want to use.

After making changes, open a new command prompt and enter java -version to verify your changes.

I think this might address what you need.

Alvin Bunk
  • 7,621
  • 3
  • 29
  • 45
  • 1
    I have 2 tabs there - User and System. The problem is I cannot disable the one in System. Why?! – peter.petrov Jan 28 '14 at 18:27
  • 1
    Hi there Peter. Looks like the Sun installer uses the registry to set that. So you'll have to use regedit and then go to "HKLM\SOFTWARE\JavaSoft\Java Runtime Environment". You may have a few keys here. Go into the keys and change "JavaHome" to the path you want, also "RuntimeLib" as well (I think Eclipse uses this). I know my Eclipse setup normally uses the "jvm.dll", but the registry was pointing to a non existant directory. Try this out - I think it should work. – Alvin Bunk Jan 28 '14 at 19:18
  • 1
    Thank you. I will have that in mind. I now uninstalled all JDKs and I don't have "HKLM\SOFTWARE\JavaSoft\Java Runtime Environment" but I do have "HKLM\SOFTWARE\JavaSoft". Thanks again. If you have other useful advices please update your answer. I will probably get back to it later too. – peter.petrov Jan 28 '14 at 19:39