Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure Chrome's Java plugin so it uses an existing JDK in the machine

When installing JDK in my machines (Windows 7), I do the following.

  1. install latest 1.7 JDK with the Oracle installer (just the JDK, no JRE)
  2. copy the install folder, to the place I really want, remove samples, etc.
  3. uninstall Java
  4. set %JAVA_HOME%, add %JAVA_HOME%\bin to %Path%

Then I synchronise that folder in all my machines so I keep it updated (with unlimited cryptography stuff, jssecacerts, java.policy, endorsed libraries, etc).

BUT this has one big caveat, when Chrome needs to use load a page that uses Java, it thinks Java is not installed and wants to install it. I don't want to install it as it would mess with my 'hand-installed' JDK.

So is there a way to configure Chrome so it uses the JDK in my disk? I have both JDK 32-bit and JDK 64-bit, so that is not a problem (I guess I would need to use the 32-bit one with Chrome).

I found a question in the Chrome project, How do I have the Chrome Java plugin reference an existing JDK without reinstalling Java?, but no replies so far...

UPDATE: for Ubuntu, see Kalyan's answer

UPDATE: I still continue to use this approach successfully, last time with 1.7.0_21 on win7

UPDATE for 1.7.45: the path in the windows registry now is [HKEY_LOCAL_MACHINE\SOFTWARE\MozillaPlugins]

like image 875
Persimmonium Avatar asked May 11 '11 09:05

Persimmonium


People also ask

Does Chrome have Java enabled?

Chrome no longer supports NPAPI (technology required for Java applets) The Java Plugin for web browsers relies on the cross-platform plugin architecture NPAPI, which had been supported by all major web browsers for over a decade.


1 Answers

Apparently, Chrome addresses a key in Windows registry when it looks for a Java Environment. Since the plugin installs the JRE, this key is set to a JRE path and therefore needs to be edited if you want Chrome to work with the JDK.

  1. Run the plugin installer anyways.
  2. Start -> Run (Winkey+R) and then type in regedit to edit the registry.
  3. Find HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\MozillaPlugins\@java.com/JavaPlugin.
  4. Export it as a reg file to say, your desktop (right-click and select Export).
  5. Uninstall the JRE (Control Panel -> Add or Remove Programs). This should delete the key above, explaining the need to export it in the first place.
  6. Open the reg file exported to your desktop with a text editor (such as Notepad++).
  7. Edit "Path" so that it matches the corresponding dll inside your JDK installation:

    REGEDIT 4  [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\MozillaPlugins\@java.com/JavaPlugin] "Description"="Oracle® Next Generation Java™ Plug-In" "GeckoVersion"="1.9"  "Path"="C:\Program Files (x86)\Java\jdk1.6.0_29\jre\bin\new_plugin\npjp2.dll"  "ProductName"="Oracle® Java™ Plug-In" "Vendor"="Oracle Corp." "Version"="160_29" 
  8. Save file.

  9. Double click modified reg file to add keys to your registry.

The REGEDIT 4 prefix at the top of the file might only be required for Windows 7 64-bit.

like image 103
Bruno Lange Avatar answered Sep 23 '22 08:09

Bruno Lange