Java icon indicating copy to clipboard operation
Java copied to clipboard

Adding Java path to registry

Open issaclin32 opened this issue 5 years ago • 5 comments

Some applications, such as Keystore Explorer[extras/keystore-explorer] and Minecraft[games/minecraft], checks Java installation through registry.

Therefore when user installs JRE through Scoop, these applications will report "Java is required" even if JRE is already installed.

The problem can be fixed by importing the content below. This can be implemented by following the pattern of VSCode package. vscode.json / vscode-install-context.reg

(I am not an expert, so I am not really sure about whether this should be added to all JRE/JDK packages.)

[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment]
"CurrentVersion"="1.8"
"BrowserJavaVersion"="11.241.2"

[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.8]
"RuntimeLib"="(JAVA PATH)\\bin\\server\\jvm.dll"
"JavaHome"="(JAVA PATH)"
"MicroVersion"="0"

[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.8.0_241]
"JavaHome"="(JAVA PATH)"
"MicroVersion"="0"
"RuntimeLib"="(JAVA PATH)\\bin\\server\\jvm.dll"

issaclin32 avatar Jan 20 '20 08:01 issaclin32

When you install adoptjdk on the official website these regkey are created I renamed them to reflect the scoop and it worked

adopt8-openj9

[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\1.8]
"JavaHome"="c:\Users\MyUser\scoop\apps\adopt8-openj9\current"

[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\8.0.252.09]
"JavaHome"="c:\Users\MyUser\scoop\apps\adopt8-openj9\current"

adopt11-openj9

[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\JDK\11]
"JavaHome"="c:\Users\MyUser\scoop\apps\adopt11-openj9\current"

[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\JDK\11.0.7.10]
"JavaHome"="c:\Users\MyUser\scoop\apps\adopt11-openj9\current"

nklowns avatar May 07 '20 09:05 nklowns

Thank you.

My own findings were that you don't need the full version as a regkey, but just the major version. But I have not been able to test it enough to implement it yet.

There are a couple of other issues too:

  1. If the full version is needed, when a new release is made, cleaning up the registry could have implications if other Java distributions are installed.
  2. If multiple Java distributions are installed within the same major release (say JDK 11), which one should be in the registry?
  3. If Java is installed globally (scoop install -g), and then one user installs it locally (in it's own profile directory), which should take preference?
  4. If Java is installed locally, for all other users on the same computer who want to use Java, what are their options?
  5. scoop reset does not take into account registry keys, so switching Java would still leave old regkeys intact.

se35710 avatar May 07 '20 10:05 se35710

@se35710 Perhaps creating a syslink folder JAVA_PATH for the current java, so whatever java is installed, the path will be immutable and, therefore, globally will assume that folder over the locally installed.

nklowns avatar May 11 '20 12:05 nklowns

If I want to execute a .jar file with JDK or JRE installed from scoop, there is no file assosiation and, if you try to execute it by java it wont work as .jar needs "javaw -jar ffilename.jar". Hope java bucket add this file association as I don't want to mess with the registry mannually

moracabanas avatar Sep 04 '20 14:09 moracabanas

Since this issue is still open I'll post .reg file for other to fix file association:

[HKEY_CLASSES_ROOT\.jar]
@="jarfile"

[HKEY_CLASSES_ROOT\jarfile]
@="Executable Jar File"

; Modify the path to javaw.exe below if using a different version or JRE
[HKEY_CLASSES_ROOT\jarfile\shell\open\command]
@="\"C:\\Users\\oschm\\scoop\\apps\\liberica17-jdk\\current\\bin" -jar \"%1\" %*"

[-HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jar]

schmitzCatz avatar Feb 29 '24 09:02 schmitzCatz