JDK-8259858 : default java version is not updated for double click jar execution
  • Type: CSR
  • Component: install
  • Sub-Component: install
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 8u291
  • Submitted: 2021-01-16
  • Updated: 2021-01-22
  • Resolved: 2021-01-22
Related Reports
CSR :  
Relates :  
Description
Summary
-------

Change how java.exe, javaw.exe and javaws.exe commands are managed in a system location by Windows Oracle JRE installers in the presence of other installed Oracle JDK/JREs.

Problem
-------

Windows Oracle JRE installer copies java.exe, javaw.exe and javaws.exe commands into separate directory and optionally adds this directory to PATH environment variable. This allows users to run Java applications without needing to provide the path to the Oracle JRE's installation folder.

Directory with java commands is added to PATH environment variable only if the installer detects that Oracle JRE being installed appears to be the latest. Otherwise if there was newer Oracle JRE installed in the system prior running the installer of the given Oracle JRE, PATH environment variable is not updated.

When Oracle JRE is uninstalled, the uninstaller checks if Oracle JRE being uninstalled was the latest and updates PATH environment variable accordingly. If there are no Oracle JRE left installed, corresponding Java entry is removed from PATH environment variable. Otherwise directory with Java commands of the latest remaining installed JRE is placed in PATH environment variable.

The logic to change value of PATH environment variable was designed to be applied to Oracle JREs. It was not meant to be applied to Oracle JDKs. 

Starting from JDK11 Oracle JRE installers were dropped on all platforms. 

Starting from JDK11 Oracle JDK installers started to add java.exe, javaw.exe, javac.exe and jshell.exe commands in a system location (JDK-8241304 CSR).

This change in functionality of JDK11 Oracle JDK installers resulted in setting wrong values in PATH environment variable by older Oracle JRE installers because older Oracle JRE installers don't take into account installed JDKs in their logic for updating PATH environment variable. 

E.g.: 
```
Install Oracle JDK11
Install Oracle JRE8
```
Expected result:
```
Running "java" from cmd.exe should invoke java.exe from Oracle JDK11.
```

Actual result:
```
Running "java" from cmd.exe invokes java.exe from Oracle JDK8.
```

Solution
--------

Change logic updating PATH environment variable of Oracle JRE installers from releases prior to JDK11. The logic should take into account that Oracle JDK installers starting from JDK11 also update PATH environment variable.

Specification
-------------

Oracle JRE installer copies java.exe, javaw.exe and javaws.exe commands in "%COMMONPROGRAMFILES(x86)%\Oracle\Java\javapath_target_{RAND}" directory. 

`{RAND}` is a random number picked by Oracle JRE installer to make unique directory name. E.g.: `C:\Program Files (x86)\Common Files\Oracle\Java\javapath_target_4108461921`

Oracle JRE installer creates/updates "%COMMONPROGRAMFILES(x86)%\Oracle\Java\javapath" link to reference "%COMMONPROGRAMFILES(x86)%\Oracle\Java\javapath_target_{RAND}" directory. 

Only "%COMMONPROGRAMFILES(x86)%\Oracle\Java\javapath" link (JDK8_javapath) is inserted in PATH environment variable by Oracle JRE installer.

JDK11 and newer Oracle JDK installers insert "%COMMONPROGRAMFILES%\Oracle\Java\javapath" link (JDK11_javapath) in PATH environment variable.

Old algorithm to update PATH environment variable during JRE install:
```
If this JRE is the latest Oracle JRE on the machine, insert JDK8_javapath at the beginning of PATH environment variable.
```

New algorithm to update PATH environment variable during JRE install:
```
If this JRE is the latest Oracle JRE on the machine, and there is *no* JDK11_javapath in PATH environment variable, insert JDK8_javapath at the beginning of PATH environment variable.

If this JRE is the latest Oracle JRE on the machine, and there is JDK11_javapath in PATH environment variable, insert JDK8_javapath after JDK11_javapath in PATH environment variable.
```

Comments
Moving to Approved.
22-01-2021

Yes, all post-11 releases will be treated similarly to 11. Updated Specification section to make it more explicit.
22-01-2021

Moving to Provisional. Are there any special considerations for release families other than 8 and 11? Will all the post-11 releases be treated similarly to 11?
22-01-2021

I've tested the fix for JDK-8260190 in local build. The new approach suggested by Bill works as expected.
21-01-2021

[~asemenyuk]please move on this CSR is still in Draft
21-01-2021

Filed JDK-8260190 to address the new fix
20-01-2021

[~kcr] Thank you for the review! Typo fixed.
20-01-2021

[~almatvee] JRE/JDK-s are ordered by version only. Release date is not used in ordering.
20-01-2021