rmoestl
rmoestl

Reputation: 3155

How to prevent that java.exe is installed in Windows' system32?

Is there a way to prevent that the Java installation routine (e.g. jdk-7u1-windows-i586.exe) copies java.exe into C:\Windows\system32 directory?

I have to install my software on a client's laptop and I don't want to break other Java applications which are already installed on the machine. In other words I want to install a private JRE which is only used by my software.

By now, I copied an already installed JRE from my computer to the client's machine.

Upvotes: 19

Views: 21653

Answers (7)

Birol Efe
Birol Efe

Reputation: 1751

Windows 10 Solution

  1. Check Java Version in Console (CMD) with java -version
  2. Check in Console (CMD) with where java, which Java Path's are enlisted.
  • If it you shows you "C:\Windows\System32" in its output, you will have a problem to get to your %JAVA_HOME%, where your wanted Java version resides.
  • Meaning, you need to get rid of "java.exe" in "C:\Windows\System32".
  1. Just uninstall the JRE in the Software ("Programs and Features") Hint: Keep in mind, do NOT the JDK, here in my case "Java SE Development Kit 8 Update (64-bit)"), but the JRE.

Upvotes: 1

timmyt123
timmyt123

Reputation: 599

All you have to do is go to Control Panel -> Programs Uninstall a program. Uninstall the old java updates and keep the newest java update and java development kit update. Your newest java update and java development kit update should have the same number.

Upvotes: 1

JonnyRaa
JonnyRaa

Reputation: 8038

I recently upgraded to java 8 and discovered this problem as the java version under system32 was still java 7. It stops you even running version as it complains about the registry keys

U:\>java -version
Error: Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVersion'
has value '1.8', but '1.7' is required.
Error: could not find java.dll
Error: Could not find Java SE Runtime Environment.

Doing the following pointed me to the culprit:

U:\>where java
C:\Windows\System32\java.exe
C:\Program Files\Java\jdk1.8.0_45\bin\java.exe

I 'solved' this problem by just deleting the java under system32! I'm unsure of what consequences this will have.

Upvotes: 6

user4246530
user4246530

Reputation: 11

I found the newest JDK still doesn't write correct code against registry. The issue is if a computer doesn't have JRE, JDK doesn't register JRE in registry correctly.

For those install JDK 1.7u72 Just add Software\JavaSoft\Java Runtime Environment as the error message indicate. And add a string entry of CurrentVersion with value 1.7. And then add Software\JavaSoft\Java Runtime Environment\1.7 and put a JavaHome string entry with value "C:\Program Files\Java\jre7". And JRE will function correctly. Blame Oracle, if you use Registry, then write correct code, otherwise don't use the Registry!

Upvotes: 1

Fernando Cabal
Fernando Cabal

Reputation: 99

I discovered yesterday that there is a problem with Java versions on Windows, as you know keeping java up to date these days is critical, especially the JRE used by Internet explorer located in the Windows system32 or syswow64 folder.

You can perform a search for java in your C: drive and look at the various executable files it finds to determine if the situation applies on a specific system.

After doing some research I find that when the Java updater runs, it only updates the files installed in the JAVA home , usually located on the program files, but it does NOT update the files located in the windows system folder. As a result and since the system folder is in the default system PATH , the usage of Internet Explorer continues to use an old version of the JAVA files ( java.exe , javaw.exe , javaws.exe )

The solution is to uninstall java using the control panel uninstall programs feature, download most recent version and install again.

Cheers! Fernando

Upvotes: 8

Esko
Esko

Reputation: 29377

One way I would try would be to create a write-only empty file with the name java.exe into the System32 folder.

Upvotes: 0

Kristof Mols
Kristof Mols

Reputation: 3557

You can just provide the JRE you want to use on your software and:

  • Set the JAVA_HOME variable before you run your application
  • Point to the correct java.exe file (e.g. ..\jre1.5.0_22\bin\java <your_java_main>)

This can be done in a *.bat file for example.

After running the *.bat file you created, all other java version will be ignored and it won't matter which versions are, or will be, installed on that pc.

Upvotes: 4

Related Questions