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

9
  • "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? Commented Jan 28, 2014 at 17:43
  • @KevinWorkman I didn't try it. I don't feel like this is the right way. Is it? Commented Jan 28, 2014 at 17:43
  • 2
    Only one way to find out! Surely simply trying it would be faster than asking strangers on the internet, right? Commented Jan 28, 2014 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. Commented Jan 28, 2014 at 17:47
  • 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. Commented Jan 28, 2014 at 17:50

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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.

3 Comments

I have 2 tabs there - User and System. The problem is I cannot disable the one in System. Why?!
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.
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.